I am using Android-ObservableScrollView library. Everything works great, but I have activity for holding fragments, so all views are encapsulated in the fragment. In activity there is only FrameLayout
for holding fragments.
So I need to use Toolbar
in my application, I have several ideas how to implement this.
Use Toolbar in activity, in this case my layout will have FrameLayout and Toolbar. In this way I have communicate with activity whenever I need to do something with toolbar, I can also obtain it by using getSupportedActionBar()
from fragment.
Use Toolbar inside fragment (in its layout) setting in each fragment view creation. And each time I change fragment I have to add new Toolbar to the activity. In some fragment I am going to have different toolbars but not in all. Is it good approach to store Toolbar inside fragment.
The problem that I can see in using second approach, if there will be more than one fragment on the screen there will be also several toolbars.
Please suggest what will be the right way in this case.
Thank you.
You should use first method. While using first method will have less problem then second one because in second method you have to define toolbar for many times which is not good programming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With