如何在文本输入布局轮廓框样式中更改浮动提示的背景颜色为透明。我认为附带的图片清楚地表明了它应该在中风上方红色,下面是白色)。我为改变背景本身所做的是:
<style name="App.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<item name="boxBackgroundColor">@color/white</item>
</style>
任何帮助都非常感谢
https://material.io/develop/android/components/components/text-fields/中查看样式文档“没有。
因此,除非您在布局中找到内部提示并手动更改背景,否则我认为该问题没有适当的解决方案。但这将是相当骇人听闻的,因为这取决于
boxBackgroundColor
保持相同的实现。
我不知道它是否有帮助,但是我设法在
outline box模式的thetextinputlayout框架内的盒子中都有统一的背景。
在我的示例中,盒子拐角具有10DP半径(TextView
TextInputEditText具有80dp(TextInputLayout
)的高度。
text_input_layout_box_radius
可绘制的绘制定义为层列表:
text_input_edit_text_height
<style name="MyTextInputLayout" parent="Widget.Design.TextInputLayout">
<item name="android:background">@drawable/text_input_background</item>
<!-- ... other customizations ... -->
</style>
text_input_background.xml
属性进行修改。您可能必须找到与提示文本高度相对应的正确填充值。
让我知道它是否有帮助!
为提示而设置单独的背景颜色感觉有些怪异,并且看起来不像是正式支持的东西,但是Sethint()方法采用char squence参数 - 也许您可以尝试使用BackgroundColorspan的spannabestring。 我尝试过,对我有用:)
旅行更新您的材料组件gradle'com.google.android.material:材料:1.4.0'
I更新此版本并解决了我的问题