Posts

Showing posts from July, 2013

customize a button with click effect on Android

Damon Usually in Android when we need button click effect we will define different state images and create a drawable as button background. But sometime it is really troublesome. coz you have to create different drawable files for different button. I am so lazy so try to find some generic ways. So I just extends the Button and when get touch event change the colors. Following codes. public class EffectButton extends Button { int textColor ; public EffectButton(Context context, AttributeSet attrs) { super(context, attrs); int[] attrsArray = new int[] { android.R.attr.textColor }; TypedArray ta = context.obtainStyledAttributes(attrs, attrsArray); textColor = ta.getColor(0, Color.TRANSPARENT); ta.recycle(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); } @Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { getBackground(...

How to customize Pie Chart View in Android

Image
Damon How to customize Pie Chart View in Android My app needs customize pie chart view. Found some open source projects. Either too complex or not so good. Spent several hours to customize own simple one. Learned how to use path and  Path.arcTo . Code first. 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 public   class  PieChartView  extends  ...