@Override protected void initSize() { super.initSize(); if (placeholderLineDrawable == null) { placeholderLineDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.placeholder_line); } Bitmap bitmap = placeholderLineDrawable.getBitmap(); placeholderLineDrawable.setBounds(new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight())); placeholderLineDrawableWidth = bitmap.getWidth() * 3; }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); paint.setTypeface(Typeface.create("", Typeface.BOLD)); paint.setTextSize((int) (textSize * BaseActivity.screen_width)); paint.setAntiAlias(true); paint.setColor(Color.rgb(100, 100, 100)); float x = Utils.measureX(paint, AVAILABLE_BALANCE_TITLE, maxwidth); canvas.drawText(AVAILABLE_BALANCE_TITLE, x, (float) (availableY * maxHeight), paint); x = Utils.measureX(paint, ACCOUNT_BALANCE_TITLE, maxwidth); canvas.drawText(ACCOUNT_BALANCE_TITLE, x, (float) ((accountY) * maxHeight), paint); x = Utils.measureX(paint, ACCOUNT_BALANCE_TITLE, maxwidth); canvas.drawText(ACCOUNT_BALANCE_TITLE, x, (float) ((accountY) * maxHeight), paint); paint.setColor(Color.BLACK); x = Utils.measureX(paint, getAvailableBalanceValue(), maxwidth); canvas.drawText( getAvailableBalanceValue(), x, (float) ((availableY + line) * maxHeight), paint); x = Utils.measureX(paint, getAccountBalanceValue(), maxwidth); canvas.drawText(getAccountBalanceValue(), x, (float) ((accountY + line) * maxHeight), paint); x = (float) (maxwidth / 2 - paint.measureText(DEPOSIT_TITLE) - placeholderLineDrawableWidth); canvas.drawText(DEPOSIT_TITLE, x, (float) ((depositY) * maxHeight), paint); x = (float) (maxwidth / 2 + placeholderLineDrawableWidth); canvas.drawText(WITHDRAWALS_TITLE, x, (float) ((depositY) * maxHeight), paint); x = (float) (maxwidth / 2 - paint.measureText(getDepositValue()) - placeholderLineDrawableWidth); canvas.drawText(getDepositValue(), x, (float) ((depositY + line) * maxHeight), paint); x = (float) (maxwidth / 2 + placeholderLineDrawableWidth); canvas.drawText(getWidthdrawalsValue(), x, (float) ((depositY + line) * maxHeight), paint); if (placeholderLineDrawable != null) { canvas.save(); // canvas.scale((float)xx, (float)xx); canvas.translate((float) (o_x), (float) ((depositY) * maxHeight) - paint.getTextSize()); placeholderLineDrawable.draw(canvas); canvas.restore(); } }