I added a style for a checkbox like below
<style name="SurveyCheckBox" >
<item name="colorControlNormal">@color/colorPrimaryLight</item>
<item name="colorControlActivated">@color/colorSecondary</item>
<item name="colorControlHighlight">@color/colorSecondaryDark</item>
</style>
It works perfectly but I also added this style for checkboxes created dynamically in a recycler view. In this case, style does not affect checkboxes. To solve this problem, I added "android:" before the item name.
<style name="SurveyCheckBox" >
<item name="android:colorControlNormal">@color/colorPrimaryLight</item>
<item name="android:colorControlActivated">@color/colorSecondary</item>
<item name="android:colorControlHighlight">@color/colorSecondaryDark</item>
</style>
This property works in API >=21 but does not work <21. Is there any solution for this problem?
recycler_view_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:id="@+id/survey_check_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_weight="8"
android:textColor="@color/colorOnBackground"
android:textSize="16sp" />
<CheckBox
android:id="@+id/survey_check_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:theme="@style/SurveyCheckBox" /> </LinearLayout>
Aucun commentaire:
Enregistrer un commentaire