如何去除Material Design中文本字段的背景色[重复]。

问题描述 投票:0回答:1

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

如何恢复到以前的风格(没有灰色背景,没有完整的边框)?

从这个。enter image description here到这个enter image description here

图片来源: 这篇Medium文章

android material-design textfield android-theme android-textinputlayout
1个回答
0
投票

这个改变是基于 用户研究 并在版本中引入了 1.1.0 材料设计库的安卓版 (MDC). 如果你想要传统的外观和感觉,官方文档推荐了这个方法。

修改一个文本字段。

<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>
© www.soinside.com 2019 - 2024. All rights reserved.