我将TextInputEditText用作文本输入,当我选择它们时,提示将按其应有的方式向上移动,但被框的轮廓覆盖。有谁知道为什么会这样?
照片:
android - 框轮廓覆盖了TextInputEditText提示-LMLPHP
代码:

<com.google.android.material.textfield.TextInputLayout
        android:id="@+id/title_layout"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColorHint="@color/grey"
        android:theme="@style/OutlinedEditText"
        app:boxStrokeColor="@color/blue"
        app:hintTextColor="@color/blue"
        app:layout_constraintTop_toBottomOf="@id/cover_art">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginStart="24dp"
            android:layout_marginEnd="24dp"
            android:hint="@string/title"
            android:inputType="textCapWords" />

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

最佳答案

TextInputEditText中删除

android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
这样,您可以在主容器(TextInputLayout)和EditText之间添加边距
android - 框轮廓覆盖了TextInputEditText提示-LMLPHP
使用:
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/title_layout"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_marginStart="24dp"
        android:layout_marginEnd="24dp"
        android:hint="...."
        ...
        >

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:inputType="textCapWords" />

    </com.google.android.material.textfield.TextInputLayout>
android - 框轮廓覆盖了TextInputEditText提示-LMLPHP

07-24 09:48