Blame view

src/com/ectrip/cyt/zxing/view/GradientShaderTextView.java 2.21 KB
90601e4f   黄灿宏   标准版本 1.扩展设备10 增...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  //package com.ectrip.cyt.zxing.view;
  //
  //import android.content.Context;
  //import android.graphics.Canvas;
  //import android.graphics.Color;
  //import android.graphics.LinearGradient;
  //import android.graphics.Matrix;
  //import android.graphics.Paint;
  //import android.graphics.Shader;
  //import android.util.AttributeSet;
  //public class GradientShaderTextView extends android.support.v7.widget.AppCompatTextView {
  //
  //  private LinearGradient mLinearGradient;
  //  private Matrix         mGradientMatrix;
  //  private Paint          mPaint;
  //  private int mViewWidth = 0;
  //  private int mTranslate = 0;
  //
  //  private boolean mAnimating = true;
  //  private int delta = 15;
  //  public GradientShaderTextView(Context ctx)
  //  {
  //    this(ctx,null);
  //  }
  //
  //  public GradientShaderTextView(Context context, AttributeSet attrs) {
  //    super(context, attrs);
  //  }
  //
  //  @Override
  //  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
  //    super.onSizeChanged(w, h, oldw, oldh);
  //    if (mViewWidth == 0) {
  //      mViewWidth = getMeasuredWidth();
  //      if (mViewWidth > 0) {
  //        mPaint = getPaint();
  //        String text = getText().toString();
  //       // float textWidth = mPaint.measureText(text);
  //        int size;
  //        if(text.length()>0)
  //        {
  //          size = mViewWidth*2/text.length();
  //        }else{
  //          size = mViewWidth;
  //        }
  //        mLinearGradient = new LinearGradient(-size, 0, 0, 0,
  //            new int[] { Color.RED, Color.GREEN, Color.BLUE},
  //            new float[] { 0, 0.5f, 1 }, Shader.TileMode.CLAMP); //边缘融合
  //        mPaint.setShader(mLinearGradient);
  //        mGradientMatrix = new Matrix();
  //      }
  //    }
  //  }
  //
  //  @Override
  //  protected void onDraw(Canvas canvas) {
  //    super.onDraw(canvas);
  //
  //    int length = Math.max(length(), 1);
  //    if (mAnimating && mGradientMatrix != null) {
  //      float mTextWidth = getPaint().measureText(getText().toString());
  //      mTranslate += delta;
  //      if (mTranslate > mTextWidth+1 || mTranslate<1) {
  //        delta  = -delta;
  //      }
  //      mGradientMatrix.setTranslate(mTranslate, 0);
  //      mLinearGradient.setLocalMatrix(mGradientMatrix);
  //      postInvalidateDelayed(30);
  //    }
  //  }
  //
  //}