我做材料设计风格的应用
我想更改AutoCompleteTextView样式
像android.support.v7.internal.widget.TintEditText中的样式
我在style.xml中添加了样式:
- <style name="AppTheme" parent="AppTheme.Base"/>
- <style name="AppTheme.Base" parent="Theme.AppCompat">
- <item name="colorPrimary">@color/colorPrimary</item>
- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
- <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>
- </style>
- <style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>
这有效,但线条颜色不会改变.
具有材质设计的EditTexts似乎使用colorControlActivated和colorControlNormal.因此,我试图在先前的样式定义中覆盖这些属性,但它没有任何效果.
我需要做什么才能让它发挥作用?
解决方法
尝试以这种方式在xml中添加用于小部件的所需样式:
- <View
- style="@style/NameOfYourTheme"
- ...
- />
如果这不起作用,你可以尝试自己设计.
您必须更改可以查找的TextView属性here.
可以通过更改应添加到样式中的android:textColor属性来更改实例的Textcolor,例如:
- <style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>
- <item name="android:textColor">#ffffffff</item>
- </style>
如果要更改edittext行,则必须更改背景属性,例如以这种方式:
- <item name ="android:background="@drawable/line_background"> </item>
并在drawables文件夹中添加一个具有类似内容的新文件line_background.xml:
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="line">
- <stroke
- android:color="#c0c000"
- android:width="3dp"></stroke>
- </shape>