<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <TextView        android:id="@+id/v1"        android:layout_width="fill_parent"        android:layout_height="wrap_content"/>    <SeekBar        android:id="@+id/seekBar1"        android:layout_width="match_parent"        android:layout_height="wrap_content" /></LinearLayout>

TestActivity.java

package test.mft;import android.app.Activity;import android.os.Bundle;import android.widget.SeekBar;import android.widget.TextView;import android.widget.Toast;public class TestActivity extends Activity {    /** Called when the activity is first created. */private SeekBar s1;private TextView v1;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        v1 = (TextView)findViewById(R.id.v1);        s1 = (SeekBar)findViewById(R.id.seekBar1);        s1.setMax(100);                int pro = 50;                s1.setProgress(pro);        v1.setText(""+pro);                                s1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {        //当停止时public void onStopTrackingTouch(SeekBar arg0) {// TODO Auto-generated method stubv1.setText(""+s1.getProgress());}//当开始拉动时public void onStartTrackingTouch(SeekBar arg0) {// TODO Auto-generated method stubv1.setText(""+s1.getProgress());}//当拉动条 改变值时public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {// TODO Auto-generated method stubv1.setText(""+s1.getProgress());}});            }}

解决不能拖到到 最大值 问题 在 layout 中 设置 android:layout_margin="3dip" 属性即可


修改 风格

<SeekBar  android:id="@+id/seekBar1"  android:layout_width="130dip"  android:layout_height="wrap_content"android:max="100"android:layout_centerVertical="true"android:layout_toLeftOf="@id/sb_value_1"android:paddingLeft="5dip"android:paddingRight="8dip"android:progressDrawable="@drawable/seekbar_bg_img"////------android:thumb="@drawable/seekbar_thumb"////------/> 

其中 @drawable/seekbar_bg_img 是背景图片 , @drawable/seekbar_thumb 是拖动按钮

图片参考附件

更多相关文章

  1. Android(安卓)图片拖动 放大
  2. Android之SeekBar
  3. 进度条及拖动条背景颜色设置(progressDrawable)
  4. 让Android自带的Gallery实现多点缩放,拖动和边界回弹效果,效果流畅
  5. android中一些view处理(拖动,定位,显示,图层)
  6. Android(安卓)系统音量最大值的定义位置以及默认值的修改方法
  7. android xml 常用控件介绍
  8. Android心率热图实现
  9. Android:上下拖动切换界面

随机推荐

  1. android 应用开发:android studio使用笔记
  2. Android(安卓)提升开发效率工具(Template
  3. Android(安卓)Unique Device ID
  4. 下半年我想做的事
  5. Android OpenGl展示视频内容
  6. android 编译模块
  7. Android音量系统分析
  8. android 采集PCM音频数据并播放(支持USB
  9. [整理]android中几种常见的尺寸
  10. 正式开始学习Android