chathura
chathura

Reputation: 3452

How to change the key label size of a custom keyboard in android

I want to change the size of the keyboard label in my custom keyboard. The code I am using is like this,

 <Keyboard
     android:keyWidth="%10p"
     android:keyHeight="50px"
     android:horizontalGap="2px"
     android:verticalGap="2px" >
 <Row android:keyWidth="32px" >
     <Key android:keyLabel="A" />
     ...
 </Row>
 ...

So the issue is, if we take the code above the letter 'A'(label) is too small in my keyboard.

In KeyBoard class I can't find any xml attribute to change the visible size of the key label.

How to change the size of the key label?

Thanks.

Upvotes: 3

Views: 2310

Answers (1)

Ellie Zou
Ellie Zou

Reputation: 2041

Size of the text for character keys. android:keyTextSize can help.

Set this in your layout xml file, like this:

<android.inputmethodservice.KeyboardView
    android:id="@+id/keyboard_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:keyBackground="@drawable/key_background"
    android:keyTextColor="@android:color/white"
    android:keyTextSize="20sp"/>

Upvotes: 4

Related Questions