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

我使用TextInputLayout,如果输入字段是必需的,我想以编程方式设置提示文本颜色和浮动标签颜色.在移动到TextInputLayout之前,我曾使用以下方法以编程方式设置提示文本颜色
textField.setHintTextColor(Color.RED);
有人可以指导我如何以编程方式为TextInputLayout设置提示文本颜色和浮动标签颜色.
在附带的屏幕截图中,我希望提示文本地址1在未聚焦时为红色,并且浮动标签地址1的焦点应为红色.
根据谷歌材料指南:
https://material.io/guidelines/components/text-fields.html#text-fields-layout
TextInputLayout提示应与错误消息的颜色相同:
但是它不是那样的,当我setError("My error")只调用下划线时,错误信息显示为红色.
如何更改此行为以考虑Google自己的指南?
目前它看起来像附加此布局:
<android.support.design.widget.TextInputLayout
android:id="@+id/layoutCurrentPW"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:errorEnabled="true">
Run Code Online (Sandbox Code Playgroud)
如何设置错误信息"密码必须至少为8个字符"到中心引力?
我尝试使用android:gravity ="center",但这不起作用.
编辑
包含EditText的布局:
<android.support.design.widget.TextInputLayout
android:id="@+id/layoutCurrentPW"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:errorEnabled="true">
<EditText
android:id="@+id/editTextCurrentPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:gravity="center"
android:hint="@string/current_password"
android:inputType="textPassword"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud) android ×4