为什么从 EditText 中选择一个长单词时布局会消失并重新出现?
Why is does the layout disappear and reappear when selecting a long word from an EditText that wrapped over to the next line?
当 select 从 EditText 编辑到达下一行的当前长词时,UI 似乎消失并重新出现。
这很难解释,但是例如,我正在输入一个词 "jdbfeergerbgherhgbrehgherhbgerbgherbgerrebghrebgrbegrebgjherbghebrghbehgbrgbejrgb",它会换行到下一个 line/s。当我 select 它而我还没有添加 space 时,比如通过长按它或使用 Google 键盘的删除手势,EditText 和它旁边的视图似乎消失然后又出现。
我试过删除 EditText 的起始约束并且它有效但是我无法通过删除起始约束来实现我想要的布局。
我尝试将 EditText 放在另一个容器中,例如 CardView 或 LinearLayout,但没有帮助。
我也试过将它们放在底部栏之外,但也没有用。
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/nav_drawer_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputEditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textCapSentences|textMultiLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/encrypt_button"
app:layout_constraintStart_toEndOf="@+id/nav_drawer_btn"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/encrypt_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我删除了填充和边距,因为我发现它们是不必要的。
我发现将 android:windowSoftInputMode="adjustResize"
添加到 activity
标记内的 Android 清单可以解决问题。
当 select 从 EditText 编辑到达下一行的当前长词时,UI 似乎消失并重新出现。
这很难解释,但是例如,我正在输入一个词 "jdbfeergerbgherhgbrehgherhbgerbgherbgerrebghrebgrbegrebgjherbghebrghbehgbrgbejrgb",它会换行到下一个 line/s。当我 select 它而我还没有添加 space 时,比如通过长按它或使用 Google 键盘的删除手势,EditText 和它旁边的视图似乎消失然后又出现。
我试过删除 EditText 的起始约束并且它有效但是我无法通过删除起始约束来实现我想要的布局。
我尝试将 EditText 放在另一个容器中,例如 CardView 或 LinearLayout,但没有帮助。
我也试过将它们放在底部栏之外,但也没有用。
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/nav_drawer_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputEditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textCapSentences|textMultiLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/encrypt_button"
app:layout_constraintStart_toEndOf="@+id/nav_drawer_btn"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/encrypt_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我删除了填充和边距,因为我发现它们是不必要的。
我发现将 android:windowSoftInputMode="adjustResize"
添加到 activity
标记内的 Android 清单可以解决问题。