简体   繁体   English

更改所有 TextInputLayout 的样式(在主题中)

[英]Change the style for all the TextInputLayout (in the theme)

I've defined an specific TextInputLayout style, modifing the Widget.MaterialComponents.TextInputLayout.OutlinedBox我定义了一个特定的 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>

Now I want to apply this style to all the TextInputLayouts.现在我想将此样式应用于所有 TextInputLayouts。 I can add the style to all the textInputLayouts, but, can I add it to my theme as the default style?我可以将样式添加到所有 textInputLayouts,但是,我可以将它作为默认样式添加到我的主题中吗? How?如何?

Thanks谢谢

Just override the textInputStyle attribute in your app theme:只需覆盖应用主题中的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM