Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name of the Material Design Checkbox in android (android.R.drawable.{checkbox})?

As in, this one below: enter image description here

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:

enter image description here

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?

like image 210
Monica Aspiras Labbao Avatar asked Dec 07 '22 22:12

Monica Aspiras Labbao


2 Answers

<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>
like image 64
Android Geek Avatar answered Dec 10 '22 11:12

Android Geek


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'

like image 24
Nrup Parikh Avatar answered Dec 10 '22 12:12

Nrup Parikh