【问题标题】:TextInputLayout remove unwanted spaceTextInputLayout 删除不需要的空间
【发布时间】:2019-07-25 07:39:33
【问题描述】:

我想要 TextInputLayout 没有任何边框和框,所以我使用下面的代码

<com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/app_name"
        app:boxBackgroundMode="none"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

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

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

但我不知道什么时候写

app:boxBackgroundMode="none"

到 TextInputLayout 然后大小是一个自动拉伸,如果你找到任何关于这个的解决方案,请帮助我,看起来很奇怪。

这是我的输出截图

【问题讨论】:

    标签: android android-layout material-design android-xml android-textinputlayout


    【解决方案1】:

    是因为app:boxBackgroundMode="none"

    尝试以下代码来实现您的设计

    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:backgroundTint="@color/white"
        app:boxStrokeColor="@color/white"
        app:boxBackgroundColor="@color/white"
        android:background="@color/white"
        android:hint="@string/app_name">
    
        <EditText
            android:background="@color/white"
            android:backgroundTint="@color/white"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    </com.google.android.material.textfield.TextInputLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-03
      • 2014-09-10
      • 2023-03-22
      • 1970-01-01
      • 2020-02-09
      • 2011-05-14
      • 1970-01-01
      相关资源
      最近更新 更多