I've been developing some application all went fine, everytime I left the main fragment the toolbar and tablayout
would also go, as soon as I was coming back to the main fragment Toolbar and tablayout
where waiting for me there.
Recently, I've tested my app on newer android 7.0 and the result is that toolbar and tablayout
don't go anywhere, they just stay at the top of any fragment.
I've tried this approach:
View view2 = getActivity().findViewById(R.id.tabs);
View view = getActivity().findViewById(R.id.toolbar);
view2.setVisibility(View.GONE);
view.setVisibility(View.GONE);
Using this method it removes tablayout and toolbar from the top, however when I go back using the back button, it also removes these two from the main fragment.
I've tried using the onResume on my main fragment, but as far as I understand unless the parent mainactivity
reloads, no result will be shown in onResume.
My question is, how can I hide toolbar and tablayout
on specific nested fragments without hiding it on my main fragment. I've looked through the other questions,everyone talks about the need of hiding them in course of scrolling.
Any help will be much appreciated.
P.s. this is how I set toolbar and tablayout on my mainactivity:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); // Setting/replace toolbar as the ActionBar
TabLayout tabLayout = (TabLayout)findViewById(R.id.tabs);
tabLayout.addTab(tabLayout.newTab().setText(getResources().getText(R.string.tab0)));
tabLayout.addTab(tabLayout.newTab().setText(getResources().getText(R.string.tab1)));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
Edit: these images will illustrate better the issue i'm facing
When I go to nested fragment (Second fragment) I remove the toolbar, but when I press back to return to the Main fragment it's also removed in there.
What I want is to hide it on my nested fragments and leave it on the main fragment.