у меня есть эта клавиатура: пользовательских цветов на softkeyboard
я думаю клавиатуры приходят из учебника основной клавиатуры.
Я хочу, чтобы изменить цвет фона для каждого ключа:
Здесь я положил все ключевые:
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height">
<Row>
<Key android:codes="113" android:keyLabel="q" android:keyEdgeFlags="left"/>
<Key android:codes="119" android:keyLabel="w"/>
<Key android:codes="101" android:keyLabel="e"/>
<Key android:codes="114" android:keyLabel="r"/>
<Key android:codes="116" android:keyLabel="t"/>
<Key android:codes="121" android:keyLabel="y"/>
<Key android:codes="117" android:keyLabel="u"/>
<Key android:codes="105" android:keyLabel="i"/>
<Key android:codes="111" android:keyLabel="o"/>
<Key android:codes="112" android:keyLabel="p" android:keyEdgeFlags="right"/>
</Row>
Я не знаю, если я могу изменить стиль оттуда
Update My KeyboardView:
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:focusableInTouchMode="true"
android:keyBackground="@drawable/message_bg"
android:keyPreviewLayout="@layout/preview">
</android.inputmethodservice.KeyboardView>
Keyboard.java
public void onInitializeInterface() {
qwertyKeyboard = new Keyboard(this, R.xml.qwerty);
symbolsKeyboard = new Keyboard(this, R.xml.symbols);
symbolsShiftedKeyboard = new Keyboard(this, R.xml.symbols_shift);
fillKeyboard = (LinearLayout) getLayoutInflater().inflate(R.layout.fill_keyboard, null);
dialogAccounts = new Builder(this);
dialogAllAccounts = new Builder(this);
usersTextView = (Button) fillKeyboard.findViewById(R.id.userTextView);
noCredentials = (Button) fillKeyboard.findViewById(R.id.noCredentials);
}
/**
* Select the view in the keyboard depending of the Globals.isLoged
*/
@Override
public View onCreateInputView() {
Globals.isKeyboard = true;
Globals.tokenKeyboard = this.getWindow().getWindow().getAttributes().token;
database = new PwdDatabaseHelper(this);
loginKeyboard = (LinearLayout) getLayoutInflater().inflate(R.layout.log_keyboard, null);
if (!Globals.isLoged) {
myMasterPassword = (EditText) loginKeyboard.findViewById(R.id.masterPasswordKeyboard);
currentKeyboardView = (KeyboardView) loginKeyboard.findViewById(R.id.keyboardView);
currentKeyboardView.setKeyboard(qwertyKeyboard);
currentKeyboardView.setOnKeyboardActionListener(this);
return loginKeyboard;
} else {
if (fillUsersAndPass() != 0) {
currentKeyboardView = (KeyboardView) fillKeyboard.findViewById(R.id.keyboardView);
currentKeyboardView.setKeyboard(qwertyKeyboard);
currentKeyboardView.setOnKeyboardActionListener(this);
noCredentials.setVisibility(View.GONE);
usersTextView.setVisibility(View.VISIBLE);
return fillKeyboard;
} else {
currentKeyboardView = (KeyboardView) fillKeyboard.findViewById(R.id.keyboardView);
noCredentials.setVisibility(View.VISIBLE);
usersTextView.setVisibility(View.GONE);
currentKeyboardView.setKeyboard(qwertyKeyboard);
currentKeyboardView.setOnKeyboardActionListener(this);
return fillKeyboard;
}
}
}
Update 2
keyboard.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true"
android:color="#8e44ad"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#e67e22"/> <!-- focused -->
<item android:color="#e74c3c"/> <!--default -->
</shape>
я имею keyPreviewLayout и она работает, но keyBackground не делают, по-прежнему показывают тот же фон – GusDev
Что вы пишете там, как ваш Drawable? Файл изображения или формы? –
изображение, его файл формы, правильно? – GusDev