【问题标题】:AutoCompleteTextView strange behaviour in LolliPop DeviceLolliPop 设备中的 AutoCompleteTextView 奇怪行为
【发布时间】:2016-12-27 21:42:17
【问题描述】:

我在布局中使用AutoCompleteTextView。但是 colorControlNormalActivate 没有按我的预期工作。

我的颜色值是#0072BA

下图为不同设备。

1.) Android Kitkat

2.) Android LolliPop

3.) 安卓棉花糖

我使用的Xml代码如下

 <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"/>

我没有给 AutoCompleteTextView 任何样式,那为什么会发生呢?

我有什么尝试:

如果我给这个样式

参考材料设计链接:

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

并赋予这种风格

 <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> 

但在 Lollipop 中没有任何变化。

这是棒棒糖版本中的错误还是我做错了什么?

【问题讨论】:

    标签: android android-layout autocompletetextview android-design-library android-5.1.1-lollipop


    【解决方案1】:

    棒棒糖版本没有错误,你只是没有用你的风格覆盖主题的风格,这样使用https://stackoverflow.com/a/26631227/4745569

    【讨论】:

    • editText中的这个颜色支持棒棒糖的主题设置,请检查是否正确。
    【解决方案2】:

    实际上这不是解决此问题的方法,但您可以将其用于整个设备的独特设计。 我已经在xml中实现了这样的edittext,为edittext设置背景为null并在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" /> 
    

    【讨论】:

    • 我使用的是AutoCompleteTextView 而不是EditText,所以这对我不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-10
    • 2014-02-03
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多