在使用 material.textfield.TextInputLayout 时,我的轮廓框会覆盖提示。我怎样才能显示提示而不让它覆盖我的盒子?
While using a material.textfield.TextInputLayout, my outlined box covers the hint. How can I display the hint without getting it covered my the box?
正如您在图片中看到的,我使用的是 material textInputEditText 和轮廓框样式。但是,我的提示 'Exchange' 被轮廓框覆盖了。我怎样才能防止这种情况发生?
这是我的 textfield.TextInputLayout 代码:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Exchange_Name"
app:errorEnabled="true"
android:paddingTop="32dp"
style="@style/TextInputLayoutStyle">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/Exchange"
android:inputType="text">
</com.google.android.material.textfield.TextInputEditText>
这是我的 styles.xml-
<style name="TextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeWidth">2dp</item>
<item name="boxStrokeColor">#FF6F9824</item>
</style>
删除 TextInputLayout
中的 android:paddingTop="32dp"
。
此外,提示应设置在 TextInputLayout
,而不是 TextInputEditText
。
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/Exchange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Exchange_Name"
app:errorEnabled="true"
style="@style/TextInputLayoutStyle"
>
正如您在图片中看到的,我使用的是 material textInputEditText 和轮廓框样式。但是,我的提示 'Exchange' 被轮廓框覆盖了。我怎样才能防止这种情况发生?
这是我的 textfield.TextInputLayout 代码:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Exchange_Name"
app:errorEnabled="true"
android:paddingTop="32dp"
style="@style/TextInputLayoutStyle">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/Exchange"
android:inputType="text">
</com.google.android.material.textfield.TextInputEditText>
这是我的 styles.xml-
<style name="TextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeWidth">2dp</item>
<item name="boxStrokeColor">#FF6F9824</item>
</style>
删除 TextInputLayout
中的 android:paddingTop="32dp"
。
此外,提示应设置在 TextInputLayout
,而不是 TextInputEditText
。
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/Exchange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Exchange_Name"
app:errorEnabled="true"
style="@style/TextInputLayoutStyle"
>