6 android 滑块和进度条
目录结构
第一步:
layout/progress_bar_layout.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ProgressBar android:id="@+id/prograssBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:max="100" android:progress="10" style="@android:style/Widget.ProgressBar.Horizontal" /> <SeekBar android:id="@+id/seekBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:max="100" android:progress="20" /> </LinearLayout>
第二步:
src/com/taofu5/ProgressBarActivity.java
package com.taofu5; import android.app.Activity; import android.os.Bundle; import android.widget.ProgressBar; import android.widget.SeekBar; public class ProgressBarActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.progress_bar_layout); SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { ProgressBar progressBar = (ProgressBar) findViewById(R.id.prograssBar); progressBar.setProgress(seekBar.getProgress()); } @Override public void onStopTrackingTouch(SeekBar seekBar) {} @Override public void onStartTrackingTouch(SeekBar seekBar) {} }); } }
第三步:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.taofu5" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".ProgressBarActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="7" /> </manifest>
效果图:
更多相关文章
- Android Glide设置图片圆角,亲测有效
- ANDROID图片压缩代码
- Android 网络下载图片
- Android:ImageView 设置图片
- Android如何截取当前View 为图片
- Android中bitmap图片透明度的处理(以撕美女衣服为例)