Change Color of Candidate view in soft keyboard programmatically

208 Views Asked by At

I have multiple background colors of the keyboard in my app user can select any color for the keyboard background. The problem I am getting is when the user selects any color to apply on the keyboard it's working but the candidate views not change the color its color is the same as the first theme. When I rotate the app screen the candidate view color is also changed. Can you help me please change the candidate view color on runtime?

1

There are 1 best solutions below

2
Umer Shahzad On

mCandidateView.setBackgroundResource( R.color.colorBlack);

@Override public void onStartInputView(EditorInfo attribute, boolean restarting) { super.onStartInputView(attribute, restarting);

    if (modeReceived == MyConstants.Companion.getTHEME_KEYBOARD_MODE_DRAWABLE()) {
        try {
            int drawablePrefs =
                    sharedPreferences.getInt(MyConstants.Companion.getTHEME_KEYBOARD_DRAWABLE(), R.color.colorBlack);
            if (mInputView != null) {
                    mInputView.setBackgroundResource(drawablePrefs);
                     mCandidateView.setBackgroundResource(drawablePrefs);
                }