【问题标题】:How to change the colour of a key text in a custom keyboard?如何更改自定义键盘中关键文本的颜色?
【发布时间】:2019-08-25 23:58:45
【问题描述】:

我正在编写一个简单的输入法编辑器,但我对更改实际 Key 的颜色有点犹豫。 这是我的keyboardView,它位于res/layout

<?xml version="1.0" encoding="utf-8"?>
<android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/keyboard"
    android:keyBackground="@drawable/key_background"
    android:keyPreviewLayout="@layout/preview">

</android.inputmethodservice.KeyboardView>

我的钥匙背景:

<item
    android:state_focused="false"
    android:state_selected="false"
    android:state_pressed="false"
    android:drawable="@drawable/normal"
    />

<item

    android:state_pressed="true"
    android:drawable="@drawable/pressed"
    />

,正常状态

<item android:bottom="2dp">
    <shape android:shape="rectangle">
        <solid android:color="@android:color/white"/>
    </shape>
</item>

和按下状态

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/keyboard_pressed"/>

</shape>

所以我坚持将实际符号(即 a、b、c 等)的颜色更改为黑色。请参阅附带的屏幕截图以及我到目前为止所获得的内容。

提前谢谢你。

【问题讨论】:

    标签: android mobile custom-keyboard ime


    【解决方案1】:

    来自KeyboardView Doc

    android:keyTextColor
    

    您可以将此属性添加到您的 KeyboardView

    用于键中标签的颜色。

    可以是颜色值,形式为“#rgb”、“#argb”、“#rrggbb”或“#aarrggbb”。

    【讨论】:

      猜你喜欢
      • 2017-02-14
      • 2017-11-04
      • 2016-12-03
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 1970-01-01
      • 2013-08-13
      • 1970-01-01
      相关资源
      最近更新 更多