У меня есть две разные панели инструментов в моей основной деятельности. Я показываю только одну панель инструментов за раз. если видна одна панель инструментов, другая исчезнет. он управляется оператором if else
две панели инструментов называются:
- общая панель инструментов
- панель инструментов поиска
эти двое имеют разный рост.
Я использую include
, чтобы прикрепить панель инструментов к своей основной деятельности.
вот xml моей основной деятельности
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activities.MainActivity" android:id="@+id/constraintLayout_main_activity">
<include
android:id="@+id/include_toolbar_general"
layout="@layout/include_toolbar_general"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_width="0dp"
android:layout_height="wrap_content"/>
<include
android:id="@+id/include_toolbar_search"
layout="@layout/include_toolbar_search"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_width="0dp"
android:layout_height="wrap_content"/>
<fragment
android:id="@+id/nav_host_fragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
app:layout_constraintTop_toBottomOf="@+id/include_toolbar_general"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:name="androidx.navigation.fragment.NavHostFragment"
app:navGraph="@navigation/main_graph"
app:defaultNavHost="true"/>
</androidx.constraintlayout.widget.ConstraintLayout>
как видите, include_toolbar_general
изначально виден. и фрагмент под ним имеет ограничениеTop_toBottomOf to include_toolbar_general
проблема в том, что в определенных условиях include_toolbar_general
исчезнет. а фрагмент пойдет вверх и как бы перекроет include_toolbar_search
(что видно, если общего тулбара нет).
я хочу сделать, когда include_toolbar_general
видимость пропадет, то фрагмент под ним будет иметь limitedTop_toBottomOf include_toolbar_search
как это сделать ?