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

回眸只為那壹抹淺笑 提交于 2019-12-23 20:25:07

问题


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.


回答1:


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"/>


来源:https://stackoverflow.com/questions/30701479/how-to-change-the-key-label-size-of-a-custom-keyboard-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!