AutoCompleteTextView strange behaviour in LolliPop

2019-03-27 16:22发布

问题:

I am using AutoCompleteTextView in my layout. But it's colorControlNormal and Activate is not Working as I expected.

My Color value is #0072BA.

Below is figure for Different Device.

1.) Android Kitkat

2.) Android LolliPop

3.) Android Marshmallow

Xml code that i used is below

 <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/md_black_1000"
        android:layout_marginTop="5dp"
        android:textSize="15sp"
        android:text="Medical Store Name"
        android:textColorHint="#999999"
        android:layout_below="@+id/search_drug_store"
        android:id="@+id/autoCompleteTextView_storename"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="10dp"/>

<AutoCompleteTextView
    android:id="@+id/autoCompleteTextView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:textSize="12sp"
    android:textColor="#999999"
    android:layout_below="@+id/autoCompleteTextView_storename"
    android:layout_marginLeft="25dp"
    android:inputType="textNoSuggestions"
    android:layout_marginRight="10dp"/>

I am not giving any style to AutoCompleteTextView then Why it's Happening ?

What I Have Try :

If i give this Style

Reference Material Design link :

http://www.materialdoc.com/autocomplete-view/

and give this style

 <style name="Autocomplete" parent="Widget.AppCompat.Light.AutoCompleteTextView">
    <item name="android:background">@color/green500</item>
    <item name="colorControlNormal">@color/amber500</item>
    <item name="colorControlActivated">@color/cyan500</item>
</style> 

But in Lollipop nothing has Change.

Is this bug in lollipop version or i am doing something wrong ?

回答1:

actually this is not solution to this problem but you can use this for unique design all over device. i have implemented for edittext like this in xml,set background null for edittext and add horizontal line below edittext.

 <EditText
        android:id="@+id/newPasswordEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:background="@null"
        android:textColor="@color/color_black"
        android:inputType="textPassword"
        android:layout_marginBottom="10dp"
        android:hint="Enter New Password"
        android:layout_marginTop="10dp"
        android:textSize="14sp"
        android:layout_below="@+id/titleTextView" />

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:orientation="horizontal"
        android:layout_marginBottom="7dp"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_below="@+id/newPasswordEditText"
        android:background="@color/color_standard_green" /> 


回答2:

There is no bug in lollipop version you just not override the style of theme with your style,use in this way https://stackoverflow.com/a/26631227/4745569