如何更改自定义键盘中键文本的颜色?

问题描述 投票:1回答:1

我正在编写一个简单的输入法编辑器,我有点卡在改变实际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>

我的key_background:

<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等)的颜色改为黑色。请查看我到目前为止所获得的附加屏幕截图。 enter image description here

先感谢您。

android mobile custom-keyboard ime
1个回答
1
投票

来自KeyboardView Doc

android:keyTextColor

您可以将此属性添加到KeyboardView

用于键中标签的颜色。

可以是“#rgb”,“#arbb”,“#rrggbb”或“#aarrggbb”形式的颜色值。

© www.soinside.com 2019 - 2024. All rights reserved.