闪动的文字效果(渲染)
来源:互联网 发布:算法导论第四版百度云 编辑:程序博客网 时间:2024/05/08 22:13
/** * Created by Administrator on 2015/12/15. */public class CustomeTextView extends TextView { private int mViewWidth; private Paint mPaint1; private Paint mPaint2; private TextPaint mPaint; private LinearGradient mLinearGradient; private Matrix mGradientMaxtix; private int mTranslate; public CustomeTextView(Context context) { super(context); } public CustomeTextView(Context context, AttributeSet attrs) { super(context, attrs);// mPaint1 = new Paint();// mPaint1.setColor(getResources().getColor(android.R.color.holo_blue_light));// mPaint1.setStyle(Paint.Style.FILL);// mPaint2 = new Paint();// mPaint2.setColor(Color.YELLOW);// mPaint2.setStyle(Paint.Style.FILL); Log.e("dd ", "CustomeTextView"); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Log.e("dd ", "onDraw"); if(mGradientMaxtix!=null){ mTranslate +=mViewWidth/5; if(mTranslate>2*mViewWidth){ mTranslate=-mViewWidth; } mGradientMaxtix.setTranslate(mTranslate,0); mLinearGradient.setLocalMatrix(mGradientMaxtix); postInvalidateDelayed(100); } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); Log.e("dd ","dddddd"); if(mViewWidth==0){ mViewWidth=getMeasuredWidth(); if(mViewWidth>0){ mPaint =getPaint(); mLinearGradient = new LinearGradient(0,0,mViewWidth,0,new int[]{Color.BLUE,0xffffffff,Color.BLUE},null, Shader.TileMode.CLAMP); mPaint.setShader(mLinearGradient); mGradientMaxtix = new Matrix(); } } } // @Override// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {//// super.onMeasure(widthMeasureSpec, heightMeasureSpec);// setMeasuredDimension(measureWidth(widthMeasureSpec), measureHeight(heightMeasureSpec));////// }//// private int measureWidth(int measureSpec) {// int result = 0;// int specMode = MeasureSpec.getMode(measureSpec);// int specSize = MeasureSpec.getSize(measureSpec);// if (specMode == MeasureSpec.EXACTLY) {// result = specSize;// } else {// result = 200;// if (specMode == MeasureSpec.AT_MOST) {// result = Math.min(result, specSize);// }// }// return result;//// }//// private int measureHeight(int measureSpec) {// int result = 0;// int specMode = MeasureSpec.getMode(measureSpec);// int specSize = MeasureSpec.getSize(measureSpec);// if (specMode == MeasureSpec.EXACTLY) {// result = specSize;// } else {// result = 200;// if (specMode == MeasureSpec.AT_MOST) {// result = Math.min(result, specSize);// }// }// return result;//// }}
0 0
- 闪动的文字效果(渲染)
- Android闪动的文字效果
- 闪动文字效果
- android群英传笔记——对现有控件进行拓展(闪动的文字效果)
- Android开发 之 LinearGradient与闪动文字效果
- LinearGradient线性渲染实现绚丽的闪动字效果
- Chrome渲染Transition时页面闪动Bug
- 精彩的文字效果
- 淡入淡出的文字效果
- 淡入淡出的文字效果
- 悬浮的文字效果
- UiTextView的提示文字效果
- 边框文字效果的样式
- 漂亮的css文字效果
- 漂亮的css文字效果
- 一个简单的tab点选动画控件(带文字效果)
- 自定义控件三部曲之绘图篇(十九)——LinearGradient与闪动文字效果
- 自定义控件三部曲之绘图篇(十九)——LinearGradient与闪动文字效果
- 关于类的多态思考。
- UVALive 4329 Ping pong(树状数组)
- poj 3264 Balanced Lineup(线段树)
- ProgressBar进度条
- IO基础知识
- 闪动的文字效果(渲染)
- Can't connect to local MySQL server through socket '/tmp/mysql.sock'错误
- Socket传输序列化对象
- StackView堆叠视图
- RSA加密算法操作的java演示
- leetcode笔记:Jump Game II
- Android 事件分发介绍
- php之与python进行socket通信
- AdapterViewFlipper自动播放图片