AmirHmZ
AmirHmZ

Reputation: 9

Changing KeyLabel font size in <key> tag for a specific key

I'm working on an android keyboard project. I wanna change font size of KeyLabel in android custom keyboard.

for example I have something like this , And I'm going to change it to this

Upvotes: 0

Views: 263

Answers (1)

AmirHmZ
AmirHmZ

Reputation: 9

After some days I found the way! I used canvas in my CustomKeyboardView class , so I just used a condition to draw it :\

public class CustomKeyboardView extends KeyboardView {
    public CustomKeyboardView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint();
        canvas.drawPaint(paint);
        paint.setColor(Color.WHITE);
        paint.setTextSize(16);
        boolean abc = false ;

        List<Keyboard.Key> keys = getKeyboard().getKeys();
        for (Keyboard.Key key : keys) {
            if (key.codes[0] == -2)
            {
                canvas.drawText("My Text", key.x, key.y, paint);
            }
        }
    }
}

Upvotes: 1

Related Questions