Как я могу сделать отдельную навигацию для каждого нижнего навигационного представления без фрагмента восстановления? - PullRequest
0 голосов
/ 04 мая 2018

Мне нужно сделать навигацию похожей на навигацию в Instagram. Первые пять фрагментов не должны создаваться после того, как один раз был вызван.

1 Ответ

0 голосов
/ 04 мая 2018

Есть три способа

  1. создание пользовательского стека фрагмента ссылка на демонстрацию
  2. создайте пять разных контейнеров фрагментов и поместите фрагмент в свой контейнер. например:

        <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>
    
  3. Сделать просмотрщик без возможности перестановки и установить OffsetLimit 5

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...