目录结构

6 android 滑块和进度条_第1张图片

第一步:

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>

效果图:

6 android 滑块和进度条_第2张图片

更多相关文章

  1. Android Glide设置图片圆角,亲测有效
  2. ANDROID图片压缩代码
  3. Android 网络下载图片
  4. Android:ImageView 设置图片
  5. Android如何截取当前View 为图片
  6. Android中bitmap图片透明度的处理(以撕美女衣服为例)

随机推荐

  1. android studio for android learning (
  2. Android的事件处理机制之基于监听的事件
  3. [置顶] 整个网络可能最完善的 Android(安
  4. 监听Android设备网络变化 - 亲测在华为Em
  5. KCommon-使用Kotlin编写,基于MVP的极速开
  6. Android数据与界面绑定工具简述
  7. 学Android开发不可不知的Android应用程序
  8. Gradle Kotlin DSL , 你知道它吗?
  9. Android(安卓)Stuido部分快捷键失灵
  10. Android定制视图及手势检测的基本示例