Previous Fragment Visible Below New Fragment
Solution 1:
I know it's too late but this answer can help others. it's not a proper solution but it's working for me. So put android:clickable="true"
and android:background="?android:attr/colorBackground"
in the root view of your fragment. hope this will work.
Solution 2:
I have faced the same problem. But I also could not find a proper solution for this. In my scenario when I open multiple apps and them come back to my app it causes the same issue with Fragments that happen on your side. But I made my app stable. I have done this by the following solution:
When your app remove from memory then again open the app then onCreate() method called of your MainActivity in which you are showing Fragments.
Here I checked the backstackEntrycount and if it is greater then 0, then remove all fragments and show the base fragment.
// Clear all fragments and show base fragment, So it will not create// issue after opening// multiple appsFrameLayoutflSliding= (FrameLayout) findViewById(R.id.fl_sliding); flSliding.post(newRunnable() { @Overridepublicvoidrun() { FragmentManagerfragmentManager= getSupportFragmentManager(); Log.i("NavigationDrawerActivity", "onCreate " + fragmentManager.getBackStackEntryCount()); if (fragmentManager.getBackStackEntryCount() > 0) { removeFragment(fragmentManager.getBackStackEntryCount()); } Log.i("NavigationDrawerActivity", "onCreate " + fragmentManager.getBackStackEntryCount()); } });
Hope it will help!
Post a Comment for "Previous Fragment Visible Below New Fragment"