使用AppCompatCheckBoxとAppCompatRadioButtonのこの
AppCompatRadioButton newRadioButton = new AppCompatRadioButton(this);
AppCompatCheckBox newCheckBox = new AppCompatCheckBox(this);
Instedを試してみてください。 あなたのXMLがあります:Javaコードのために今すぐ
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/cbSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorAccent" //This to set your default button color
android:checked="true"/>
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/rb"
app:buttonTint="@color/colorAccent" //This to set your default button color
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
: はのためのプログラムで色を変更するにはAppCompatRadioButtonまたはAppCompatCheckBoxコールsetSupportButtonTintListをColorStateList
ColorStateList colorStateList = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_enabled} //enabled
},
new int[] {getResources().getColor(R.color.colorPrimary) }
);
を作成 。
AppCompatRadioButton radioButton = (AppCompatRadioButton) findViewById(R.id.rb);
radioButton.setSupportButtonTintList(colorStateList);
AppCompatCheckBox cbSelected = (AppCompatCheckBox) findViewById(R.id.cbSelected);
cbSelected.setSupportButtonTintList(colorStateList);
用背景画像 – Androider
しかし、私は、画像 –
を添付していない色を設定したいアンドロイドサポートライブラリで利用可能な任意の関数はありますか? – Androider