Search code examples
androidcheckboxkeyboardandroid-appcompat

How to use AppCompatCheckBox inside InputMethodService?


I am creating a custom keyboard with InputMethodService, there are checkboxes inside my keyboard and i need to change the color. I've found that you can use this for min API 21+

<Checkbox
  android:buttonTint="@color/red" />

and with AppCompat

<Checkbox
  app:buttonTint="@color/red" />

but when i run my keyboard, the color does not change at all

is it because im not running on a AppCompatActivity?

Edit: Screenshot of my checkbox enter image description here


Solution

  • Like @Mike M. said in the comments, i need to use ContextThemeWrapper. This is how i do it

    ContextThemeWrapper ctx = new ContextThemeWrapper(getContext(), R.style.AppTheme);
    inflate(ctx, R.layout.my_layout, view);