改变的EditText底线颜色appcompat V7 [英] Changing EditText bottom line color with appcompat v7
问题描述
我使用appcompat V7获得Android上5和不太一致的外观。它的工作原理相当好。不过,我无法弄清楚如何改变底线颜色和口音的颜色EditTexts。可能吗?
I am using appcompat v7 to get the look consistent on Android 5 and less. It works rather well. However I cannot figure out how to change the bottom line color and the accent color for EditTexts. Is it possible?
我试图定义一个定制安卓editTextStyle
(参见下文),但我只成功地改变了全背景颜色或文本颜色,但不是底线,也没有强调色。是否有一个具体的属性值使用?我必须通过 Android的使用自定义绘制的图像:背景
属性?是不是可以指定在六色?
I have tried to define a custom android:editTextStyle
(cf. below) but I only succeeded to change the full background color or text color but not the bottom line nor the accent color. Is there a specific property value to use? do I have to use a custom drawable image through the android:background
property? is it not possible to specify a color in hexa?
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:editTextStyle">@style/Widget.App.EditText</item>
</style>
<style name="Widget.App.EditText" parent="Widget.AppCompat.EditText">
???
</style>
据Android的API 21源,EditTexts与材料设计似乎使用 colorControlActivated
和 colorControlNormal
。因此,我试图覆盖在previous样式定义这些属性,但它没有任何效果。也许appcompat不使用它。不幸的是,我找不到appcompat与材料设计的最后一个版本的源代码。
According to android API 21 sources, EditTexts with material design seem to use colorControlActivated
and colorControlNormal
. Therefore, I have tried to override these properties in the previous style definition but it has no effect. Probably appcompat does not use it. Unfortunately, I cannot find the sources for the last version of appcompat with material design.
推荐答案
最后,我已经找到了解决办法。它只是由覆盖值 colorControlActivated
, colorControlHighlight
和 colorControlNormal
你的应用主题定义,而不是你的EditText的风格。然后,想用这个主题无论什么活动,你的愿望。下面是一个例子:
Finally, I have found a solution. It simply consists of overriding the value for colorControlActivated
, colorControlHighlight
and colorControlNormal
in your app theme definition and not your edittext style. Then, think to use this theme for whatever activity you desire. Below is an example:
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">#c5c5c5</item>
<item name="colorControlActivated">@color/accent</item>
<item name="colorControlHighlight">@color/accent</item>
</style>
这篇关于改变的EditText底线颜色appcompat V7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!