| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.animation; |
| 18 |
|
| 19 |
import android.content.Context; |
| 20 |
import android.content.res.TypedArray; |
| 21 |
import android.util.AttributeSet; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class AlphaAnimation extends Animation { |
| 30 |
private float mFromAlpha; |
| 31 |
private float mToAlpha; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public AlphaAnimation(Context context, AttributeSet attrs) { |
| 40 |
super(context, attrs); |
| 41 |
|
| 42 |
TypedArray a = |
| 43 |
context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.AlphaAnimation); |
| 44 |
|
| 45 |
mFromAlpha = a.getFloat(com.android.internal.R.styleable.AlphaAnimation_fromAlpha, 1.0f); |
| 46 |
mToAlpha = a.getFloat(com.android.internal.R.styleable.AlphaAnimation_toAlpha, 1.0f); |
| 47 |
|
| 48 |
a.recycle(); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public AlphaAnimation(float fromAlpha, float toAlpha) { |
| 59 |
mFromAlpha = fromAlpha; |
| 60 |
mToAlpha = toAlpha; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
@Override |
| 67 |
protected void applyTransformation(float interpolatedTime, Transformation t) { |
| 68 |
final float alpha = mFromAlpha; |
| 69 |
t.setAlpha(alpha + ((mToAlpha - alpha) * interpolatedTime)); |
| 70 |
} |
| 71 |
|
| 72 |
@Override |
| 73 |
public boolean willChangeTransformationMatrix() { |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
@Override |
| 78 |
public boolean willChangeBounds() { |
| 79 |
return false; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
@Override |
| 86 |
public boolean hasAlpha() { |
| 87 |
return true; |
| 88 |
} |
| 89 |
} |