File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
lib/src/main/java/in/arjsna/lib Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 2424 * Created by arjun on 8/2/16.
2525 */
2626public class PassCodeView extends View {
27+ private boolean DEBUG = false ;
2728 private final int KEYS_COUNT = 12 ;
2829 private final String eraseChar = "\u232B " ;
2930 private final int KEY_PAD_COLS = 3 ;
@@ -150,10 +151,20 @@ protected void onDraw(Canvas canvas) {
150151
151152 private void drawKeyPad (Canvas canvas ) {
152153 paint .setTextSize (getResources ().getDimension (R .dimen .key_text_size ));
154+ paint .setTextAlign (Paint .Align .CENTER );
155+ float centerHalf = (paint .descent () + paint .ascent ()) / 2 ;
153156 for (KeyRect rect : keyRects ) {
154157 canvas .drawText (rect .value ,
155- rect .rect .centerX (),
156- rect .rect .centerY (), paint );
158+ rect .rect .exactCenterX (),
159+ rect .rect .exactCenterY () - centerHalf , paint );
160+ if (DEBUG ) {
161+ canvas .drawLine (rect .rect .left ,
162+ rect .rect .centerY (),
163+ rect .rect .right , rect .rect .centerY (), paint );
164+ canvas .drawLine (rect .rect .centerX (),
165+ rect .rect .top ,
166+ rect .rect .centerX (), rect .rect .bottom , paint );
167+ }
157168 }
158169 }
159170
You can’t perform that action at this time.
0 commit comments