Мне нужно сделать навигацию похожей на навигацию в Instagram. Первые пять фрагментов не должны создаваться после того, как один раз был вызван.
Есть три способа
создайте пять разных контейнеров фрагментов и поместите фрагмент в свой контейнер. например:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal"> <FrameLayout android:id="@+id/fragment_container_post" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> <FrameLayout android:id="@+id/fragment_container_message" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:visibility="gone" /> <FrameLayout android:id="@+id/fragment_container_add_post" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:visibility="gone" /> <FrameLayout android:id="@+id/fragment_like" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:visibility="gone" /> <FrameLayout android:id="@+id/fragment_profile" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:visibility="gone" /> </LinearLayout> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_gravity="bottom" app:itemIconTint="@drawable/selector_bottombar_item" app:itemTextColor="@drawable/selector_bottombar_item" android:background="@color/white" app:onNavigationItemSelected="@{viewModel.onNavigationClick}" app:menu="@menu/bottombar_menu" xmlns:android="http://schemas.android.com/apk/res/android" /> </LinearLayout>
Сделать просмотрщик без возможности перестановки и установить OffsetLimit 5
OffsetLimit