dimanche 23 octobre 2016

How to change TextField and Checkboxes color when they have focus/they are checked?

I have a small problem with colors for few elements in my simple application. As you can see in the image the TextField, when it has focus, and checkboxes, when they are checked, are green, which is the default color.

Screenshot

This is the code:

    <android.support.design.widget.TextInputLayout
          android:id="@+id/input_name_label"
          android:layout_width="match_parent"
          android:layout_height="wrap_content">

          <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:hint="@string/home_text_field"
                android:ems="10"
                android:id="@+id/input_name"
                android:layout_marginTop="@dimen/activity_vertical_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin" />

    </android.support.design.widget.TextInputLayout>

and

    <CheckBox
          android:text="@string/argInformatica"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/scelta3"
          android:layout_marginTop="@dimen/activity_vertical_margin"
          android:layout_marginLeft="@dimen/activity_horizontal_margin"
          android:layout_marginRight="@dimen/activity_horizontal_margin"
          android:layout_below="@+id/scelta2"
          android:layout_centerHorizontal="true"
          android:visibility="visible" />

For the checkboxes I found to add this line to the xml tag

    android:buttonTint="@color/colorAccent"

but it doesn't work as I would like, the checkbox will have accent color also if it is not checked.

Any idea? Thanks in advance




Aucun commentaire:

Enregistrer un commentaire