This might sound stupid, but I'm seriously a newbie at Android programming. I have looked this up on the Internet, but it looks like nobody ever had difficulties with this. I am making a soft keyboard for our school Android project. I intended to make my own background for this keyboard, but I couldn't figure out how to change the keyboard's background. I made a buttonbgselector.xml file in my drawable dir:
<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>
I tried setting the background here:
@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;
}
And the keys are still the same, nothing changed.
Android phones don't require third-party apps, as they already allow you to change keyboard color. However, iPhone users can use third-party apps to create a similar effect. Here's how to do so using Gboard, Google's keyboard app. Install the Gboard app from the App Store.
Customize your keyboard with a custom theme Open the app > tap Set Keyboard Theme > select a color option from the options, including red, blue, green, pink, black or gray options.
There is a XML-Attribute called keyBackground. Just set this attribute to a drawable and it should be fine.
Add this attrbute to the KeyboardView in input.xml:
<KeyboardView android:keyBackground="@drawable/buttonbgselector" .../>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With