Android:stateに応じてTextの色を変更する・・・ColorStateList
テキストの色をButton等のstateに合わせて変えることを、
xmlでやらずに自前でやるにはColorStateListを作成し、それをsetTextColorすれば良い。
以下、select状態で色が変わるTextViewを作成するサンプル
xmlでやらずに自前でやるにはColorStateListを作成し、それをsetTextColorすれば良い。
以下、select状態で色が変わるTextViewを作成するサンプル
TextView text = new TextView(this);
text.setTextColor( new ColorStateList(
new int[][] {
new int[]{ android.R.attr.state_selected },
new int[]{ -android.R.attr.state_selected },
},
new int[] {
Color.argb(0xff,0xff,0xff,0xff),
Color.argb(0xff,0x8f,0x8f,0x8f),
}
) );
コメント
コメントを投稿