ManuelPeinado / FadingActionBar

Android library implementing a fading effect for the action bar, similar to the one found in the Play Music app
Apache License 2.0
2.87k stars 677 forks source link

FadingActionBar with FragmentTabHost #113

Open vishwasdoth opened 9 years ago

vishwasdoth commented 9 years ago

Can I use FadingActionBar with FragmentTabHost?

I have FragmentTabHost with three Fragments and each has ListView. Above Fragment tabs, I have header layout which I want to parallax hide on ListView scroll.

manaqvi commented 9 years ago

Yes. It can be possible by placing header layout (where you want parallax effect) within parent fragment which is in your case is "FragmentTabHost". then you can simply make effect using this:

                     FadingActionBarHelper mFadingHelper = new FadingActionBarHelper()
                     .actionBarBackground(R.drawable.ab_background_light)
                     .headerLayout(R.layout.header)
                     .contentLayout(R.layout.fragment_tab_host)
                     .lightActionBar(true);

Note: make sure your three listview fragments are in fragment_tab_host's java class. even a better approach to use a viewpager within FragmentTabHost to hold all three fragment (List fragments).

vishwasdoth commented 9 years ago

Thanks for your response. I am not getting one thing here. What do you mean by "Note: make sure your three listview fragments are in fragment_tab_host's java class."

Here is my setup... mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.tab_fragments_holder);

mTabHost.addTab(tabSpec, Fragment1.class, args); mTabHost.addTab(tabSpec, Fragment2.class, args); mTabHost.addTab(tabSpec, Fragment3.class, args);

each fragment has different layout file.. like fragment_layout1.xml, fragment_layout2.xml

is this setup correct?

vishwasdoth commented 9 years ago

I am still stuck on this. Any help would be great help.