我正在尝试设置TextInputLayout的样式:
<style name="AppTheme.TextInputLayout.OutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeColor">@color/text_input_layout_outlined_box_stroke</item>
<item name="hintTextColor">@color/text_input_layout_outlined_box_stroke</item>
</style>
这就是颜色选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/green_2" android:state_focused="true" />
<item android:color="@color/green_2" android:state_hovered="true" />
<item android:color="@color/green_2" android:state_enabled="false" />
<item android:color="@color/green_2" />
</selector>
这就是我的观点:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="@string/surname">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
为什么这会按预期应用于视图:
style="@style/AppTheme.TextInputLayout.OutlinedBox"
主题不起作用:
android:theme="@style/AppTheme.TextInputLayout.OutlinedBox"
我没有得到这两者之间的区别...
编辑:也许我已经找到了这个以避免重复每个视图:
<item name="textInputStyle">@style/AppTheme.TextInputLayout.OutlinedBox</item>
您可以定义样式
: