I'm developing a keyboard for android. How to change the text color of the keys?

余生长醉 提交于 2019-12-11 13:34:46

问题


How to change the text color of the keys?

Here is my keyboard layout.

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

key_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- Bottom 2dp Shadow -->
    <item android:top="4dp"
        android:left="2dp"
        android:right="2dp"> 
        <shape android:shape="rectangle" >
            <solid android:color="@color/key_shadow" />
            <corners android:radius="4dp"/>
        </shape>
    </item>

    <!-- White Top color -->
    <item android:bottom="4px" 
        android:top="4dp"
        android:left="2dp"
        android:right="2dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/white" />
            <corners android:radius="4dp" />
        </shape>
    </item>

</layer-list>

回答1:


Please look into this you will get an idea for your problem. http://developer.android.com/reference/android/inputmethodservice/KeyboardView.html

android:keyTextColor="your color code"



回答2:


U can use android:keyTextColor attribute: like

android:keyTextColor="@android:color/black"


来源:https://stackoverflow.com/questions/28604932/im-developing-a-keyboard-for-android-how-to-change-the-text-color-of-the-keys

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