lundi 11 mai 2015

Do we need to specific its UI components (Spinner, EditText) colors explicitly when using AppCompat

Previously, I have a DialogFragment, which I doesn't specific its UI components (Spinner, EditText) colors explicitly.

dialog_fragment_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"       
    android:paddingLeft="10dp" 
    android:paddingRight="10dp"
    android:orientation="vertical" >

    <Spinner
        android:id="@+id/country_spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="200dp"
        android:layout_marginBottom="10dp" /> 

    <EditText
        android:id="@+id/name_edit_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textNoSuggestions|textCapWords"
        android:maxLength="50"
        android:ems="10" >

        <requestFocus />
    </EditText>

</LinearLayout>

I'm using

  • SherlockActionBar
  • Theme.Sherlock.Light.DarkActionBar
  • android:minSdkVersion="10", android:targetSdkVersion="21"

It looks as following

enter image description here

After migrating to

  • AppCompat
  • Theme.AppCompat.Light.DarkActionBar
  • android:minSdkVersion="10", android:targetSdkVersion="22"

It looks like the following

enter image description here

I was wondering, am I doing something wrong during my migration process? Is there really a need, to specific color for DialogFragment UI components (Spinner, EditText) colors explicitly?

Is there a way, to make the DialogFragment looks good, without having the manually assigning colors to Spinner, EditText, ... just like what we do (We let system to decide the best color for Spinner, EditText, ...) when we use SherlockActionBar?

Note, I don't specific theme in Activity or DialogFragment. I only specific theme in Application, and I expect my Activity or DialogFragment will inherit from Application's.

<application
    android:theme="@style/..." >

Aucun commentaire:

Enregistrer un commentaire