【问题标题】:How to remove background color of text fields in Material Design [duplicate]如何在材料设计中删除文本字段的背景颜色[重复]
【发布时间】:2020-06-17 11:38:07
【问题描述】:

在较新版本的材料设计库中,文本字段的外观发生了变化。

如何将其恢复为旧样式(没有灰色背景且没有完整边框)?

从这里: 对此:

图片来源:this Medium article

【问题讨论】:

    标签: android material-design textfield android-theme android-textinputlayout


    【解决方案1】:

    此更改基于 user research,并在 Android 材料设计库 (MDC) 的 1.1.0 版本中引入。如果您想要传统的外观,官方文档推荐这种方法:

    更改单个文本字段:

    <com.google.android.material.textfield.TextInputLayout
        ...
        style="@style/Widget.Design.TextInputLayout">
        ...
    </com.google.android.material.textfield.TextInputLayout>
    

    更改主题中的所有文本字段:

    <style name="Theme.MyApp" parent="Theme.MaterialComponents.*">
        ...
        <item name="textInputStyle">@style/Widget.MyApp.TextInputLayout</item>
    </style>
    
    <style name="Widget.MyApp.TextInputLayout" parent="Widget.Design.TextInputLayout">
        <!-- My custom attrs -->
    </style>
    

    【讨论】:

      猜你喜欢
      • 2016-12-02
      • 1970-01-01
      • 1970-01-01
      • 2016-10-22
      • 2020-08-19
      • 1970-01-01
      • 1970-01-01
      • 2020-11-28
      • 2020-07-10
      相关资源
      最近更新 更多