【问题标题】:Change the style for all the TextInputLayout (in the theme)更改所有 TextInputLayout 的样式(在主题中)
【发布时间】:2019-07-30 08:31:22
【问题描述】:

我已经定义了一个特定的 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>

现在我想将此样式应用于所有 TextInputLayouts。我可以将样式添加到所有 textInputLayouts,但是,我可以将它作为默认样式添加到我的主题吗?怎么样?

谢谢

【问题讨论】:

    标签: android material-design android-textinputlayout material-components-android material-components


    【解决方案1】:

    只需覆盖应用主题中的 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>
    

    【讨论】:

      猜你喜欢
      • 2020-05-21
      • 2021-03-20
      • 1970-01-01
      • 2012-05-07
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 2010-09-25
      • 2016-10-24
      相关资源
      最近更新 更多