gpt4 book ai didi

android - 如何更改 EditText 中的线条颜色

转载 作者:IT老高 更新时间:2023-10-28 12:55:10 25 4
gpt4 key购买 nike

我正在我的布局 xml 文件中创建一个 EditText

但我想将 EditText 中的颜色线从 Holo 更改为(例如)红色。那怎么办?

enter image description here

最佳答案

这是您可以用于所有 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"

enter image description here


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

更新 4AndroidX版本

  <androidx.appcompat.widget.AppCompatEditText

app:backgroundTint="@color/blue_gray_light" />

关于android - 如何更改 EditText 中的线条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24677414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com