简体   繁体   中英

Tabs on top and bottom of the screen

I'm trying to build a view that will have standard tabs on the bottom and action bar tabs in the upper part of the screen.
I've tried using FragmentTabHost together with TabLayout but with no success since they both call getSupportFragmentManager() so one cancels another.
I've also thought about using deprecated TabLayoutActivity but I'm using AppCompat theme so all my activities have to inherit AppCompatActivity .

Is there a way for bottom tab to start activities and upper one fragments, or at least both starting fragments that work?

Exanmple

You can have 2 framelayouts (bottom,middle).

On bottom framelayout you will have a fragment with buttons as tabs, when you click on each button you will send back to activity which button clicked.

On middle framelayout you can have a TabLayout fragment and if you prefer also 1 fragment for each tab in the tablayout.

One of the solutions is to use getChildFragmentManager() available in the support library to have a Fragment inside another Fragment.
The outer one with FragmentTabHost can be controlled by main fragment manager getFragmentManager() and inner one with TabLayout by child fragment manger getChildFragmentManager() .
Here's an example with nested fragments .
Still looking for a viable solution with Activity and a Fragment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM