做了一个拖动滑块改变数值的demo
下附上代码:
<SeekBar
android:id="@+id/myseekbar"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:thumb="@drawable/slider"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/mytext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:layout_marginTop="30dp"
android:layout_gravity="center"
android:text="0"
/>
myseek=(SeekBar) findViewById(R.id.myseekbar);
mytext=(TextView)findViewById(R.id.mytext);
myseek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
mytext.setText(String.valueOf(i));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
附上效果图: