Bottom Navigation View With Navigation Control transaction failing some times

耗尽温柔 提交于 2020-01-16 09:03:12

问题


while moving from one tab to another tab on bottom navigation view some times i am getting the app theme color is applying to enter fragment

like this is my code

``code from activity```

override fun onSupportNavigateUp() = NavigationUI.navigateUp(navController!!, null)

private fun setUpNavigation() {
    navController = Navigation.findNavController(this, R.id.frameRoot)
    bottomNavigationView.setupWithNavController(navController)

    bottomNavigationView.setOnNavigationItemSelectedListener { item ->
        onNavDestinationSelected(item, navController)
    }
}

layout design

<?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"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <fragment
            android:id="@+id/frameRoot"
            android:layout_width="match_parent"
            android:name="androidx.navigation.fragment.NavHostFragment"
            app:defaultNavHost="true"
            android:layout_height="match_parent"
            app:navGraph="@navigation/dashboard_graph"
            android:layout_above="@+id/navigation"
            android:background="@color/white_color"/>

    <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_gravity="bottom"
            android:background="#FFFFFF"
            style="@style/AppTheme.BottomDark"
            android:visibility="visible"
            app:elevation="5dp"
            app:labelVisibilityMode="labeled"
            app:itemTextAppearanceActive="@color/theme_color"
            app:itemBackground="@drawable/nav_item_background"
            app:itemIconTint="@drawable/tab_selected"
            app:itemTextColor="@drawable/tab_selected"
            app:menu="@menu/dashboard_menu"/>


    <androidx.appcompat.widget.AppCompatImageView
            android:layout_width="@dimen/_40sdp"
            android:layout_height="@dimen/_40sdp"
            android:layout_marginBottom="@dimen/_60sdp"
            android:layout_marginEnd="@dimen/_24sdp"
            android:id="@+id/fbSettings"
            android:src="@drawable/theme_setting_img"
            android:layout_gravity="bottom|end"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:backgroundTint="@color/app_button" app:fabSize="normal"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

navigation graph

<?xml version="1.0" encoding="utf-8"?>
<navigation 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/dashboard"
            app:startDestination="@id/icStudio">

    <fragment
            android:id="@+id/icStudio"
            android:name="com.augray.avmessage.ui.avatar.AvatarStudioFragment"
            android:label="AvatarStudioFragment"
            tools:layout="@layout/fragment_avatar_studio">
        <argument android:name="FilePath" app:argType="string" android:defaultValue='""'/>
        <argument android:name="scene_type" app:argType="string" android:defaultValue="studio_scene"/>
    </fragment>


    <fragment
            android:id="@+id/icARChat"
            android:name="com.augray.avmessage.ui.dashboard.fragments.archat.ARChatFragment"
            android:label="ARChatFragment"
            tools:layout="@layout/fragment_ar_chat">
    </fragment>


    <fragment android:id="@+id/icARWorld"
              android:name="com.augray.avmessage.ui.dashboard.fragments.arworld.ARWorldFragment"
              android:label="ARWorldFragment"
              tools:layout="@layout/fragmennt_ar_world">
    </fragment>

    <fragment android:id="@+id/icVRWorld"
              android:name="com.augray.avmessage.ui.dashboard.fragments.vrworld.VRWorldFragment"
              android:label="VRWorldFragment"
              tools:layout="@layout/fragment_vr_world"/>

    <fragment android:id="@+id/icProfile"
              android:name="com.augray.avmessage.ui.dashboard.fragments.profile.ProfileFragment"
              android:label="ProfileFragment"
              tools:layout="@layout/fragment_profile"/>

</navigation>

please help me what was the issue thank you for advance

note: removed image

来源:https://stackoverflow.com/questions/57392089/bottom-navigation-view-with-navigation-control-transaction-failing-some-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!