简体   繁体   中英

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

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>

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"

你可以使用android:keyTextColor属性:like

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM