如何在Android中设置键盘背景

如何在Android中设置键盘背景,android,keyboard,background,Android,Keyboard,Background,这听起来可能很愚蠢,但我真的是Android编程的新手。 我在网上查过,但似乎没有人遇到过这样的问题。 我正在为我们学校的Android项目制作一个软键盘。 我打算为这个键盘制作自己的背景,但我不知道如何更改键盘的背景。 我在我的drawable目录中创建了一个buttonbgselector.xml文件: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:dr

这听起来可能很愚蠢,但我真的是Android编程的新手。 我在网上查过,但似乎没有人遇到过这样的问题。 我正在为我们学校的Android项目制作一个软键盘。 我打算为这个键盘制作自己的背景,但我不知道如何更改键盘的背景。 我在我的drawable目录中创建了一个buttonbgselector.xml文件:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/button" />
<item
android:state_pressed="true"
android:drawable="@drawable/buttonpressed" />
<item
android:state_checkable="true"
android:drawable="@drawable/button" />
<item
android:state_checkable="true"
android:state_pressed="true"
android:drawable="@drawable/buttonpressed" />
<item
android:state_checkable="true"
android:state_checked="true"
android:drawable="@drawable/button" />
<item
android:state_checkable="true"
android:state_checked="true"
android:state_pressed="true"
android:drawable="@drawable/buttonpressed" />
</selector>

键仍然相同,没有任何更改。

有一个XML属性,名为。 只需将此属性设置为drawable,就可以了

将此属性添加到input.xml中的KeyboardView:



感谢您的回复,但遗憾的是,这没有起作用。我想知道是不是因为我的png图像,所以我非常感谢你的回答。
@Override public View onCreateInputView() {
    mInputView = (KeyboardView) getLayoutInflater().inflate(
            R.layout.input, null);
    mInputView.setBackgroundResource(R.drawable.buttonbgselector);
    mInputView.setOnKeyboardActionListener(this);
    mInputView.setKeyboard(mQwertyKeyboard);
    return mInputView;
}
<KeyboardView android:keyBackground="@drawable/buttonbgselector" .../>