<?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. 进度条及拖动条背景颜色设置(progressDrawable)
  3. 让Android自带的Gallery实现多点缩放,拖动和边界回弹效果,效果流畅
  4. android中一些view处理(拖动,定位,显示,图层)
  5. Android 系统音量最大值的定义位置以及默认值的修改方法
  6. Android ListView拖动时背景变黑的解决方法
  7. android Button拖动
  8. Android button 拖动
  9. 关于安卓开发实现拖动条和星级评论

随机推荐

  1. 各种Layout用到的一些重要的属性
  2. android 验证码
  3. Android纠正Activity横竖屏切换的生命周
  4. 在Android上远程调试JavaScript
  5. android 开发对gif解码(适配android 4.2、
  6. Develop one game for playing
  7. RealtiveLayout(相对布局属性)
  8. Android Studio apk系统签名和版本描述的
  9. Android RecyclerView DividerItemDecora
  10. Android控件之EditText(输入文本框控件)