自定义键盘未应用颜色更改的问题

时间:2019-02-11 22:44:49

标签: android android-layout

我已经遵循this tutorial并创建了自己的键盘,但是无法更改其键的背景颜色。

keyboard.xml

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="3px"
android:keyWidth="10%p"
android:keyHeight="60dp"
android:keyBackground="@color/color_green" 
android:keyTextColor="@color/color_red"
android:verticalGap="3px">

keyboard_view.xml

<android.inputmethodservice.KeyboardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyboard_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@color/all_white">
</android.inputmethodservice.KeyboardView>

MyInputMethodService.java

    @Override
public View onCreateInputView() {
    keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard_view, null);
    keyboardView.setPreviewEnabled(false);
    keyboard = new Keyboard(this, R.xml.number_pad);
    keyboardView.setKeyboard(keyboard);
    keyboardView.setOnKeyboardActionListener(this);
    return keyboardView;
}

enter image description here

我曾尝试更改android:keyBackgroundandroid:keyTextColor,但没有任何变化,但是如果我在同一文件中更改某些键值,它将起作用。

0 个答案:

没有答案