Reputation: 649
I need this default drawable so I can programmatically style it to my auto-generated checkboxes, like so:
checkBox.setButtonDrawable(R.drawable.checkbox_style);
I need this checkbox drawable because Samsung GT-I9300 with Android 4.3 (Jellybean) overrides this style above, like so:
This is my app theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorPrimary</item>
<item name="colorControlNormal">#88FFFFFF</item>
<item name="colorControlActivated">#88FFFFFF</item>
<item name="colorControlHighlight">@color/colorAccent</item>
<item name="android:textColorHint">@android:color/white</item>
</style>
What is it's name, like android.R.drawable.(...)
, please?
Upvotes: 4
Views: 6762
Reputation: 386
do you want like this for check box
checkBox.setButtonDrawable(R.drawable.abc_btn_check_material);
or you can use AppCompatCheckBox like this
LinearLayout llParent=(LinearLayout)findViewById(R.id.llParent);
AppCompatCheckBox appCompatCheckBox = new AppCompatCheckBox(this);
appCompatCheckBox.setText("agree or not");
llParent.addView(appCompatCheckBox);
and add the dependancy for design support lib build.gradle file
compile 'com.android.support:appcompat-v7:23.3.0'
Upvotes: 6
Reputation: 9225
<style name="Widget.CompoundButton.CheckBox">
<item name="android:background">@android:drawable/btn_check_label_background</item>
<item name="android:button">?android:attr/listChoiceIndicatorMultiple</item>
</style>
Upvotes: 6
Reputation: 18978
if you want to use default drawable then no need to set setButtonDrawable
. just use App compart(support v7) its work for Android API 7 to current Android API 23(also animated checkbox).
add this in compile 'com.android.support:appcompat-v7:23.2.0'
in build.gradle
use **App Compart Theme ** with colorAccent
Upvotes: 2