I am working on fragments, but there is a problem when i switch from one fragment to other view overlap eachother.
I am using following code to switch fragments.
getSupportFragmentManager() .beginTransaction() .add(R.id.mainContainer, new SecondsFragment()) .addToBackStack(null) .commit(); I know that using add() will only add newer fragment over the previous one. I dont want to use replace because it reloads everything when i return to that fragment using onBackPress() e-g i have REST API calls in first fragment when i open second fragment using replace() function and return to first fragment it will again call that REST API, which is not good for UX.
If i use add() to load second fragment, the view of second fragment overlaps view of first fragment, and returning to first fragment not call that REST API (my desired behaviour).
I also know that by setting background of fragments xml parent view, this issue can be resolved but then it will also cause accidental clicks on first fragments views again bad for UX, i also read in SO by setting parent view clickable to true will resolve this issue too, but as other developers said it is just a hack not a proper solution.
I am expecting users like commonsware to address this question.
Any suggestions/comments are highly welcome.
Thanks in Advance.
I am expecting users like commonsware to address this questionand why