mardi 11 août 2015

Android Studio CheckBox Animation

I am currently trying to add a settings page with custom checkboxes. The checkboxes extend the entire width of the screen, however the default click animation of these checkboxes makes it look extremely awkward: click animation

I have tried to enclose the checkbox in a linear layout but it does not restrict this animation. Do I need to create a custom animation for this checkbox? If so, how do I restrict the click animation to just the container of the checkbox? Posted below is a portion of the code.

                  <TextView
                        android:id="@+id/emailField"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="10dp"
                        android:layout_marginTop="10dp"
                        android:text="@string/pref_header_push_notifications"
                        android:textColor="@color/settingsText"
                        android:textSize="20sp"/>
                    <View
                        android:layout_width="fill_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="15dp"
                        android:layout_marginTop="15dp"
                        android:background="@color/lightgray" />
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:weightSum="9">

                        <CheckBox
                            android:id="@+id/receipts"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_alignParentEnd="true"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentRight="true"
                            android:layout_alignParentStart="true"
                            android:layout_alignParentTop="true"
                            android:button="@null"
                            android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
                            android:text="@string/pref_title_receipts" />
                    </LinearLayout>


                    <CheckBox
                        android:id="@+id/offers"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:button="@null"
                        android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
                        android:text="@string/pref_title_offers"
                        android:checked="false"
                        android:layout_marginTop="20dp"
                        android:layout_marginBottom="20dp" />


                    <CheckBox
                        android:id="@+id/messages"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:button="@null"
                        android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
                        android:text="@string/pref_title_messages" />
                    <View
                        android:id="@id/separator"
                        android:layout_width="fill_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="10dp"
                        android:layout_marginTop="15dp"
                        android:background="@color/lightgray" />

Thank you very much.




Aucun commentaire:

Enregistrer un commentaire