我正在我的布局 xml 文件中创建一个 EditText
但我想将 EditText 中的颜色线从 Holo 更改为(例如)红色。 那怎么办?
最佳答案
这是您可以用于所有 View 的最佳工具,并且非常感谢@Jérôme Van Der Linden,它是免费的。 .
Android Holo Colors Generator 让您可以轻松创建 Android 组件,例如 EditText
或为您的 Android 应用程序使用您自己的颜色的微调器。它将生成所有必需的 9-patch 资源以及相关的 XML 可绘制对象和样式,您可以将它们直接复制到您的项目中。
http://android-holo-colors.com/
更新 1
此域似乎已过期,但该项目是开源项目,您可以在此处找到
https://github.com/jeromevdl/android-holo-colors
试试看
这张图片放在EditText
android:background="@drawable/textfield_activated"
更新 2
对于 API 21 或更高版本,您可以使用 android:backgroundTint
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Underline color change"
android:backgroundTint="@android:color/holo_red_light" />
更新 3
现在我们有了支持 AppCompatEditText
注意:我们需要使用 app:backgroundTint 而不是 android:backgroundTint
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Underline color change"
app:backgroundTint="@color/blue_gray_light" />
更新 4 AndroidX版本
<androidx.appcompat.widget.AppCompatEditText
app:backgroundTint="@color/blue_gray_light" />
关于android - 如何更改 EditText 中的线条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24677414/