[英]TextInputLayout is being overridden by the system keyboard
我是 android 的新手。我有 TextInputLayout 和 MaterialButton 的布局。 如果您輸入的值太大,edittext 會逐漸下降。 為什么會出現這樣的錯誤? 我在 inte.net 上找到的信息對我沒有幫助。 如何解決? 請幫幫我。
如果將 layout_height 設置為 input_layout 為 0dp,則最初 edittext 看起來太大
這是它的樣子:
我的布局文件:
``` <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:background="@color/black">
<androidx.appcompat.widget.Toolbar
android:id="@+id/activity_comment_toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/left_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/right_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_end="16dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/comment_input_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/comment_input_background"
android:hint="Введите текст комментария"
android:paddingStart="16dp"
android:paddingTop="10dp"
app:endIconDrawable="@drawable/ic_cancel_black_24dp"
app:endIconMode="clear_text"
app:errorTextAppearance="@style/TextInputLayoutAppearance"
app:errorTextColor="@color/error"
app:hintTextColor="@color/gray1"
app:layout_constraintBottom_toTopOf="@+id/activity_comment_apply_button"
app:layout_constraintEnd_toEndOf="@id/right_guideline"
app:layout_constraintStart_toEndOf="@id/left_guideline"
app:layout_constraintTop_toBottomOf="@id/activity_comment_toolbar"
app:layout_constraintVertical_bias="0.0">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/comment_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textMultiLine|textNoSuggestions"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/activity_comment_apply_button"
style="@style/CommentApplyButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/comment_activity_button_apply"
app:layout_constraintBottom_toTopOf="@id/bottom_guideline"
app:layout_constraintEnd_toEndOf="@id/right_guideline"
app:layout_constraintStart_toEndOf="@id/left_guideline" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/bottom_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_end="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout> ```
清單文件:
``` <activity
android:name=".MainActivity"
android:windowSoftInputMode="stateVisible|adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> ```
您可以為您的 textinputlayout 使用 max-line 屬性,將其添加到您的 textinputlayout 代碼中:
android:maxlines="your desired max lines number"
希望這可以幫助!!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.