问题描述
我正在使用InputMethodService创建自定义键盘,键盘内部有复选框,我需要更改颜色。我发现您可以将此用于最小API 21 +
<Checkbox
android:buttonTint="@color/red" />
以及AppCompat
<Checkbox
app:buttonTint="@color/red" />
但是当我操作键盘时,颜色完全不变
是因为我不在AppCompatActivity
上运行吗?
解决方法
就像@Mike M.在评论中说的那样,我需要使用ContextThemeWrapper
。这就是我的方法
ContextThemeWrapper ctx = new ContextThemeWrapper(getContext(),R.style.AppTheme);
inflate(ctx,R.layout.my_layout,view);