Guest User

Untitled

a guest
Jul 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <ImageView
  2. android:src="@drawable/logosmall"
  3. android:adjustViewBounds="true"
  4. android:layout_width="wrap_content"
  5. android:layout_height="wrap_content"
  6. android:id="@+id/imageLogo"/>
  7.  
  8. <com.mydomainhere.customImageView
  9. android:src="@drawable/logosmall"
  10. android:adjustViewBounds="true"
  11. android:layout_width="wrap_content"
  12. android:layout_height="wrap_content"
  13. android:id="@+id/imageLogo"/>
  14.  
  15. public class customImageView extends ImageView{
  16. private float mAlpha = 5f;
  17. private float mDelta = 1f;
  18.  
  19. public customImageView(Context context) {
  20. super(context);
  21. }
  22.  
  23. public customImageView(Context context, AttributeSet attrs) {
  24. super(context);
  25. this.setAlpha((int)mAlpha);
  26.  
  27. }
  28.  
  29.  
  30. @Override
  31. public void onDraw(Canvas canvas) {
  32. super.onDraw(canvas);
  33.  
  34. if (mAlpha > 254){
  35. mDelta = -1f;
  36. }
  37. if (mAlpha < 1){
  38. mDelta = 1f;
  39. }
  40. mAlpha = mAlpha + mDelta;
  41. this.setAlpha((int)mAlpha);
  42.  
  43. this.invalidate();
  44. }
  45.  
  46. }
Add Comment
Please, Sign In to add comment