简体   繁体   English

如何在没有娱乐片段的情况下为每个底部导航视图进行单独导航?

[英]How can I make seperate navigation for each bottom nav view without recreation fragment?

I need to make navigation like Instagram navigation.我需要像 Instagram 导航一样进行导航。 First five fragment should not be created after that called once.在调用一次之后不应创建前五个片段。

There are three way有三种方式

  1. make custom stack of fragment link of demo制作演示片段链接的自定义堆栈
  2. make five different fragment container and push fragment in it's container.制作五个不同的片段容器并将片段推送到它的容器中。 for example:例如:

     <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. Make viewpager with not swipable and set OffsetLimit 5使 viewpager 不可滑动并设置OffsetLimit 5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何防止在底部导航视图中重新创建片段? - How to prevent Fragment recreation in Bottom Navigation View? 底部导航和碎片娱乐 - Bottom Navigation & Fragment Recreation 在片段内使用导航主机片段和底部导航视图? - Using nav host fragment and bottom navigation view inside fragment? 返回片段后,如何在底部导航视图中更改所选项目? - How can i change the selected item in bottom Navigation View while going to the back fragment? 我怎样才能使导航底部栏的一项不会给我带来片段? - How can I make that an item of Navigation Bottom Bar doesn't bring me a fragment? 如何在底部导航视图中的每个项目名称下方添加行(视图)? - How Can I add line(view) below each of the item name in bottom navigation view? 如何使用带有底部导航视图的全屏片段? - How to use fullscreen fragment with a bottom navigation view? CollapsingToolbarLayout 使 RecyclerView 在片段视图重新创建后无法滚动直到底部 - CollapsingToolbarLayout makes RecyclerView NOT scrollable until bottom after fragment view recreation Android Studio 底部栏导航:如何添加到每个片段? - Android Studio Bottom Bar Nav: How do I add to each fragment? 如何在视图底部制作菜单 - How can I make a menu at the bottom of a view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM