如何设置TextInputLayout的轮廓框浮动提示背景色 [英] How to set TextInputLayout's outlined box floating hint background color

查看:545
本文介绍了如何设置TextInputLayout的轮廓框浮动提示背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将文本输入布局轮廓框样式中的浮动提示的背景颜色更改为透明.我认为所附图片清楚地说明了问题.在笔划上方应为红色,在下方应为白色).我所做的更改背景本身的操作是:

How to change the background color of the floating hint in a text input layout outline box style to transparent. I think the attached picture clearly states the issue It should be red above the stroke and white below). What I did to change the background itself was:

<style name="App.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxBackgroundColor">@color/white</item>
</style>

非常感谢您的帮助

推荐答案

如果您查看 https://material.io/develop/android/components/text-fields/您可以看到填充文本视图"支持boxBackgroundColor属性,而轮廓文本字段"才不是.

If you look at the style docs in https://material.io/develop/android/components/text-fields/ you can see the "Filled text view" supports the boxBackgroundColor attribute while the "Outlined text field" does not.

因此,除非您在布局中找到内部提示TextView并手动更改背景,否则我认为没有适当的解决方案.但这将是很棘手的,因为这取决于TextInputLayout保持不变的实现.

So I don't think there's a proper solution to this problem unless you find the inner hint TextView within the layout and change the background manually. But that would be quite hacky since it depends on the implementation of the TextInputLayout staying the same.

这篇关于如何设置TextInputLayout的轮廓框浮动提示背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆