我正在尝试为我的Android应用程序编写新的自定义样式.我需要给风格ERRORTEXT其设置后出现setError在EditText.
我该如何定制它的风格?
例如:我想在style.xml中设置background白色和textColor:蓝色等

我正在使用TextInputLayoutHelper小部件,以便遵循浮动标签输入的材料准则。当前看起来像这样:
在活动onCreate功能中,我具有:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val passwordInputLayout = this.findViewById<TextInputLayoutHelper>(R.id.input_layout_password)
passwordInputLayout.error = "8+ characters and at least one uppercase letter, a number, and a special character (\$, #, !)"
passwordInputLayout.isErrorEnabled = true
}
Run Code Online (Sandbox Code Playgroud)
和我的小部件xml看起来像...
<TextInputLayout
android:id="@+id/input_layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/EditTextTheme"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorAppearance"
app:passwordToggleDrawable="@drawable/asl_password_visibility"
app:passwordToggleEnabled="true"
app:passwordToggleTint="?colorControlNormal">
<EditText
android:id="@+id/password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/set_a_password"
android:inputType="textPassword"
android:singleLine="true" />
</TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我想在错误文本的右侧的错误/提示文本(感叹号三角形)中放置一个图标。
我发现使用了一个实现,setError(text, drawable)但我正在使用的Kotlin实现setError不可用。
所以我尝试了:
val warningIcon = …Run Code Online (Sandbox Code Playgroud)