Я переключился с ConstraintLayout на CoordinatorLayout, чтобы избежать перекрытия закусочной с моим видом снизу. Хотя он работал очень хорошо на экране только с панелью инструментов, RecyclerView и плавающей кнопкой, на втором экране мне очень трудно добавить представление под RecyclerView, избегая при этом его перекрытия с RecyclerView
Мое лучшее решение (ниже) заключалось в том, чтобы добавить paddingBottom
attribute примерно 80dp
в recyclerView. Похоже, это решает проблему, но когда закусочная находится в ВВЕРХ, нижний вид android:id="@+id/item_cl_add"
снова будет перекрываться с recyclerView. Конечно, я могу добавить больше paddingBottom
, чтобы компенсировать размер закусочной, но это означает, что я потеряю около 20dp недвижимости (плохая идея).
Я проверил много веб-сайтов, но не смог найти простого решения.
ниже мой последний код, который все еще перекрывается на закусочной
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:id="@+id/item_col_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".item.ItemActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include
android:id="@+id/item_toolbar"
layout="@layout/toolbar" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp"
android:layout_marginTop="8dp"
tools:listitem="@layout/list_item"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/item_cl_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_dodgeInsetEdges="bottom"
android:layout_gravity="bottom">
<AutoCompleteTextView
android:id="@+id/item_ac_add"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:hint="@string/item_edit_text_hint"
android:imeOptions="actionDone"
android:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_b_add"
app:layout_constraintTop_toTopOf="parent"
tools:targetApi="o" />
<Button
android:id="@+id/item_b_add"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="8dp"
android:background="@color/colorForeground"
android:stateListAnimator="@null"
android:text="+"
android:textColor="@android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Ниже приведен скриншот без закусочной (Хорошо).
Ниже приведен снимок экрана с закусочной (не очень хорошо).