更改所有 TextInputLayout 的样式(在主题中)
Change the style for all the TextInputLayout (in the theme)
我定义了一个特定的 TextInputLayout 样式,修改 Widget.MaterialComponents.TextInputLayout.OutlinedBox
<style name="TextInput" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxBackgroundMode">outline</item>
<item name="boxBackgroundColor">@color/inputBackground</item>
<item name="boxCollapsedPaddingTop">12dp</item>
</style>
现在我想将此样式应用于所有 TextInputLayout。我可以将样式添加到所有 textInputLayouts,但是,我可以将它作为默认样式添加到我的主题吗?怎么样?
谢谢
只需覆盖应用主题中的 textInputStyle
属性:
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<item name="textInputStyle">@style/TextInput</item>
<!-- Default value is: <item name="textInputStyle">@style/Widget.MaterialComponents.TextInputLayout.FilledBox</item> -->
</style>
我定义了一个特定的 TextInputLayout 样式,修改 Widget.MaterialComponents.TextInputLayout.OutlinedBox
<style name="TextInput" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxBackgroundMode">outline</item>
<item name="boxBackgroundColor">@color/inputBackground</item>
<item name="boxCollapsedPaddingTop">12dp</item>
</style>
现在我想将此样式应用于所有 TextInputLayout。我可以将样式添加到所有 textInputLayouts,但是,我可以将它作为默认样式添加到我的主题吗?怎么样?
谢谢
只需覆盖应用主题中的 textInputStyle
属性:
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<item name="textInputStyle">@style/TextInput</item>
<!-- Default value is: <item name="textInputStyle">@style/Widget.MaterialComponents.TextInputLayout.FilledBox</item> -->
</style>