相信大家在许多App中都见到过带字母索引的界面
多余话不说了直接上代码
/**
* @date:2015/1/16
* @author:dongxiaogang
* @description: 自定义字母搜索控件
*/
public class LetterSlideBar extends View{
private Paint mPaint;
private static String[] letters={
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","#"};
private String mCurrentLetter;
public LetterSlideBar(Context context) {
this(context,null);
}
public LetterSlideBar(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public LetterSlideBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
mPaint=new Paint();
mPaint.setAntiAlias(true);
mPaint.setTextSize(sp2px(12));
mPaint.setColor(Color.parseColor("#000000"));
}
private float sp2px(int sp) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,