アプリケーションにカスタム キーボードがあり、ユーザー設定に基づいて実行時にテキストの色を変更したいと考えています。XML で KeyTextColor を設定することはできますが、プログラムで設定する属性はありません。これは私がXmlで設定する方法です:
<?xml version="1.0" encoding="utf-8"?>
<app:android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:keyBackground="@drawable/key_background"
android:keyPreviewHeight="@dimen/dp_0"
android:keyTextSize="40sp"
android:keyTextColor="#00C853">//I set green text color here
</app:android.inputmethodservice.KeyboardView>
プログラムから同じ KeyTextColor を設定したい。何か案は?