【问题标题】:Remove bottom line from TextInputEditText从 TextInputEditText 中删除底线
【发布时间】:2020-01-24 12:13:42
【问题描述】:

我需要删除TextInputEditText 的底线我将背景设置为透明和空,但没有任何效果。

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bg_textinput_layout"
    android:hint="@string/app_name">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/transparent"/>

</com.google.android.material.textfield.TextInputLayout>

bg_textinput_layout

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/white"/>

<stroke android:width="@dimen/spacing_1"
    android:color="@color/hint_text_color"/>
</shape>

【问题讨论】:

  • 你不需要这个 bg_textinput_layout 背景。只需使用 boxBackgroundColor 即可获得一个白框。
  • 我将这种样式 Widget.MaterialComponents.TextInputLayout.OutlinedBox 应用于 textinputlayout,现在它正在工作
  • 这里是简单的解决方案stackoverflow.com/questions/57063519/…

标签: android layout android-edittext android-textinputlayout material-components-android


【解决方案1】:

您可以应用 app:boxStrokeWidth="0dp"app:boxStrokeWidthFocused="0dp"(或使用具有相同 boxBackgroundColor 值的选择器的app:boxStrokeColor 属性)。

   <com.google.android.material.textfield.TextInputLayout
       app:boxStrokeWidth="0dp"
       app:boxStrokeWidthFocused="0dp"
       ...>

对于没有背景和边框的白框:

<com.google.android.material.textfield.TextInputLayout
    app:boxStrokeWidth="0dp"
    app:boxStrokeWidthFocused="0dp"
    app:boxStrokeColor="#FFF"
    app:boxBackgroundColor="#FFF"
    ...>

【讨论】:

  • 为什么我们不能用 FilledBox 隐藏底线?
猜你喜欢
  • 2019-11-25
  • 2020-06-03
  • 2013-10-21
  • 2019-01-16
  • 1970-01-01
  • 2017-11-23
  • 2022-11-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多