我知道这个问题以前已经被问过了,但是那些解决方案在我的情况下都不起作用。我想改变编辑文本的底部线条颜色,并尝试了其他链接中的解决方案,将以下行添加到styles.xml主题中:
<item name="colorControlNormal">#c5c5c5</item>
但是在我的情况下,这种方法似乎不起作用。我尝试更改基础主题,但仍然对我无效。 而且我想在我的应用程序中对所有editext进行此操作,而不仅仅是一个。 有其他方法可以做到吗?
我知道这个问题以前已经被问过了,但是那些解决方案在我的情况下都不起作用。我想改变编辑文本的底部线条颜色,并尝试了其他链接中的解决方案,将以下行添加到styles.xml主题中:
<item name="colorControlNormal">#c5c5c5</item>
但是在我的情况下,这种方法似乎不起作用。我尝试更改基础主题,但仍然对我无效。 而且我想在我的应用程序中对所有editext进行此操作,而不仅仅是一个。 有其他方法可以做到吗?
编辑位于 values 文件夹下的 Style.xml。
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">#c5c5c5</item>
<item name="colorControlActivated">#c5c5c5</item>
<item name="colorControlHighlight">#c5c5c5</item>
</style>
?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#ffffff" />
</shape></item>
</selector>
并将此文件设置为:
android:background="@drawable/edittextborder"
。
android:backgroundTint="@color/blue"
我更喜欢使用9 patch图像来自定义编辑文本的颜色。 Android 9 patch generator online
这是一个非常棒的在线工具生成器,适用于所有小部件。Android Holo colors
生成并下载到每个dpi文件夹中,并使用背景应用它。
试试这个,
.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:padding="5dp">
<EditText
android:id="@+id/text_to"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/customborder" //.xml file for edittext
android:clickable="true"
android:padding="5dip"
android:text="Text_to"
android:textColor="@color/black"
android:textSize="@dimen/font_normal_size" />
</LinearLayout>
customborder.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="2dp"
android:topRightRadius="0dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
</shape>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:top="-2dp" android:right="-2dp" android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#FFFFFF" />
</shape>
</item>
</layer-list>