0

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

  • May you please check my answer? let me know if it helps – blueware Oct 23 '16 at 08:17
  • Possible duplicate of [Changing EditText bottom line color with appcompat v7](http://stackoverflow.com/questions/26574328/changing-edittext-bottom-line-color-with-appcompat-v7) – Ali Bdeir Oct 23 '16 at 08:29

2 Answers2

1

Have this style in your styles.xml:

<style name="inputColors">
    <item name="colorControlActivated">@color/thirdColor</item> <!-- In focus -->
    <item name="colorControlNormal">#9e9e9e</item> <!-- not touched -->
</style>

Then, to your CheckBox/EditText, add:

android:theme="@style/inputColors"

It should work

Ali Bdeir
  • 4,151
  • 10
  • 57
  • 117
0

Into which location (directory/file) do these styles have to go? Regardless of where I tried so far: I am only getting an error that the tag "style" is unknown/illegal... :-(

mmo
  • 3,897
  • 11
  • 42
  • 63