Android 具有轮廓但背景透明的TextInputLayout

Android 具有轮廓但背景透明的TextInputLayout,android,android-textinputlayout,material-components-android,Android,Android Textinputlayout,Material Components Android,如果boxBackgroundColor是透明的,则boxStroke不可见 <style name="OutlinedRoundedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox"> <item name="boxBackgroundColor">@android:color/transparent</item> <item name="boxStro

如果
boxBackgroundColor
是透明的,则boxStroke不可见

<style name="OutlinedRoundedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
    <item name="boxBackgroundColor">@android:color/transparent</item>
    <item name="boxStrokeColor">@android:color/white</item>
    <item name="boxStrokeWidth">4dp</item>
</style>

@android:彩色/透明
@android:彩色/白色
4dp
那么,是否只有使用自定义背景才能拥有透明的TextInputLayout而没有轮廓

例如:


如果您发布了它的设计,那么它会更容易理解。对于这个解决方案,如果我理解正确,您需要添加这两个内容

在样式中添加:

<style name="InputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">@color/text_input_box</item>
</style>

@颜色/文本输入框
添加颜色资源:

<?xml version="1.0" encoding="utf-8"?>   
  <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/red_bright" android:state_focused="true" />
    <item android:color="@color/red_bright" android:state_hovered="true" />
    <item android:color="@color/red_bright" />
  </selector>

如果这是您想要的,此解决方案将具有类似的内容

如果您发布了它的设计,那么它会更容易理解。对于这个解决方案,如果我理解正确,您需要添加这两个内容

在样式中添加:

<style name="InputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">@color/text_input_box</item>
</style>

@颜色/文本输入框
添加颜色资源:

<?xml version="1.0" encoding="utf-8"?>   
  <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/red_bright" android:state_focused="true" />
    <item android:color="@color/red_bright" android:state_hovered="true" />
    <item android:color="@color/red_bright" />
  </selector>

如果这是您想要的,此解决方案将具有类似的内容

是的,这是我需要的,现在我看到了大纲,我有了透明背景,不需要设置自定义背景是的,这是我需要的,现在我看到大纲,我有了透明背景,不需要设置自定义背景