竖直滑动条 ,用起来比较方便
/**
* 设置滑动方向,
* 0代表从下向上滑
* 1代表从下向上滑
*
* @param orientation
*/
public void setOrientation(int orientation)
默认的状态
verticalSeekBar.setUnSelectColor(Color.GREEN);
verticalSeekBar.setSelectColor(Color.RED);
// 单位为dp
verticalSeekBar.setmInnerProgressWidth(10);
//单位为px
// verticalSeekBar.setmInnerProgressWidthPx(15);
verticalSeekBar.setThumb(R.mipmap.star);
verticalSeekBar.setThumb(R.mipmap.star);
//单位是px
verticalSeekBar.setThumbSizePx(100, 100);
//单位是dp
// verticalSeekBar.setThumbSize(50,50);
verticalSeekBar.setProgress(80);
verticalSeekBar.setOnSlideChangeListener(this);
/**
* 开始滑动
* @param slideView
* @param progress
*/
@Override
public void onStart(VerticalSeekBar slideView, int progress) {
}
/**
* 滑动过程中
* @param slideView
* @param progress
*/
@Override
public void onProgress(VerticalSeekBar slideView, int progress) {
}
/**
* 结束滑动
* @param slideView
* @param progress
*/
@Override
public void onStop(VerticalSeekBar slideView, int progress) {
}
- 在github下载项目 ,项目源码
- 把源码拷到自己项目下
- 在布局中引用
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ccc" tools:context="zhuyuguang.com.verticalseekbar.MainActivity"> <zhuyuguang.com.verticalseekbar.view.VerticalSeekBar android:id="@+id/verticalSeekBar" android:layout_width="80dp" android:layout_height="200dp" /> </LinearLayout>
- 在代码中查找 private VerticalSeekBar verticalSeekBar;
private VerticalSeekBar verticalSeekBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
verticalSeekBar = (VerticalSeekBar) findViewById(R.id.verticalSeekBar);
}