【发布时间】:2019-02-11 22:44:49
【问题描述】:
我已关注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;
}
我尝试更改 android:keyBackground 和 android:keyTextColor,但没有任何变化,但如果我更改同一文件中的某些键值,它会起作用。
【问题讨论】: