本文实例为大家分享了Android字母导航栏的具体代码,供大家参考,具体内容如下
<>强效果强>
/* *
*自定义字母导航栏
*
*总的来说就四步
* 1、测量控件尺寸{@link # onMeasure (int, int)}
* 2,绘制显示内容(背景以及字符){@link # onDraw(画布)}
* 3处理滑动事件{@link # onTouchEvent (MotionEvent)}
* 4、暴露接口{@link # setOnNavigationScrollerListener (OnNavigationScrollerListener)}
*
* @attr customTextColorDefault//导航栏默认文字颜色
* @attr customTextColorDown//导航栏按下文字颜色
* @attr customBackgroundColorDown//导航栏按下背景颜色
* @attr customLetterDivHeight//导航栏内容高度间隔
* @attr customTextSize//导航栏文字尺寸
* @attr customBackgroundAngle//导航栏背景角度
*/公开课CustomLetterNavigationView扩展视图{
私有静态最终字符串标签=癈ustomLetterNavigation”;//导航内容
私人String [] mNavigationContent;//导航栏内容间隔
私人mContentDiv浮动;//导航栏文字大小
私人mContentTextSize浮动;//导航栏文字颜色
私人int mContentTextColor;//导航栏按下时背景颜色
私人int mBackgroundColor;//导航栏按下时圆角度数
私人int mBackGroundAngle=0;//导航栏按下时文字颜色
私人int mDownContentTextColor;
私人TextPaint mTextPaint;
私人油漆mPaintBackgrount;
私人布尔mEventActionState=false;
私人字符串mCurrentLetter=" ";
私人>
& lt; declare-styleable name=" CustomLetterNavigationView比;
& lt; attr name==把丈?癱ustomTextColorDefault”格式比;
& lt; attr name==把丈?癱ustomTextColorDown”格式比;
& lt; attr name==把丈?癱ustomBackgroundColorDown”格式比;
& lt; attr=name=" customLetterDivHeight "格式"维度"/比;
& lt; attr=name=" customTextSize "格式"维度"/比;
& lt; attr name==罢?癱ustomBackgroundAngle”格式比;
& lt;/declare-styleable>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。