领透酷医云安卓客户端

CustomView.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.linkdialy.mobile.kuyicloud.widget;
  2. import android.content.Context;
  3. import android.graphics.Canvas;
  4. import android.graphics.Color;
  5. import android.util.AttributeSet;
  6. import android.widget.RelativeLayout;
  7. public class CustomView extends RelativeLayout {
  8. final static String MATERIALDESIGNXML = "http://schemas.android.com/apk/res-auto";
  9. final static String ANDROIDXML = "http://schemas.android.com/apk/res/android";
  10. final int disabledBackgroundColor = Color.parseColor("#E2E2E2");
  11. int beforeBackground;
  12. // Indicate if user touched this view the last time
  13. public boolean isLastTouch = false;
  14. public CustomView(Context context, AttributeSet attrs) {
  15. super(context, attrs);
  16. }
  17. @Override
  18. public void setEnabled(boolean enabled) {
  19. super.setEnabled(enabled);
  20. if (enabled)
  21. setBackgroundColor(beforeBackground);
  22. else
  23. setBackgroundColor(disabledBackgroundColor);
  24. invalidate();
  25. }
  26. boolean animation = false;
  27. @Override
  28. protected void onAnimationStart() {
  29. super.onAnimationStart();
  30. animation = true;
  31. }
  32. @Override
  33. protected void onAnimationEnd() {
  34. super.onAnimationEnd();
  35. animation = false;
  36. }
  37. @Override
  38. protected void onDraw(Canvas canvas) {
  39. super.onDraw(canvas);
  40. if (animation)
  41. invalidate();
  42. }
  43. }