我将TextInputEditText
用作文本输入,当我选择它们时,提示将按其应有的方式向上移动,但被框的轮廓覆盖。有谁知道为什么会这样?
照片:
代码:
<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
之间添加边距使用:
<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>