Tabs on top and bottom of the screen - java

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?

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.

Related

Android Fragments in Tablayout with dot sliders

In Android development I want to achieve interface seen in image:
Screenshot
What I want basically is activity should have two tabs and in each of them there should be a fragment and that fragment should have dot indicator so that user can swipe to second menu of fragmen or other fragment in same tab.
Please help with what kind of logic should I implement.

BottomSheetDialogFragment behaviour disorder when added nested fragment in Android

I've a BottomSheetDialogFragment inside a RecyclerView, when is clicked a button BottomSheet is showing. BottomSheetDialog expanding when scrolling down and collapsing when scroll finished on top normally.
But when I place the RecyclerView inside a fragment and lay the fragment to BottomSheetDialog; BottomSheet behaviours not working on the fragment, only works RecyclerView scrolling. On the other hand the behaviours work other places on BottomSheet. How to enable the behaviours as in the first?
You should check that your container layout has app:layout_behavior="#string/bottom_sheet_behavior"> and check that any listener/event you define extra, otherwise BottomSheetDialog normally behaive as you expect.

How to dynamically change Toolbar from activity inside ViewPager (TabLayout)

I'm struggling with Toolbar Button and ViewPager with TabLayout inside my app. I have multiple Toolbar Buttons, that I want to change dynamically (Add or remove icon/button on Toolbar, and set different onClickListener for each Fragment) inside Fragment loaded inside TabLayout. The main problem here is that ViewPager load 2 fragments in a row in order to provide the scroll animation, but there is no method in order to know if the fragment is really displayed or not... (Except setUserVisibleHint, but this method is deprecated, and doesn't seems to be really reliable), so does someone have a solution in order for my app to run great with that behaviour? (Changing dynamically the icon on my Toolbar inside the Fragment)
Thanks!
Try implementing the logic inside the onResume of your Fragment. onResume basically means that this fragment is visible for the user. This should solve your problem. Hope it helps :)

combine tab view with bottom navigation

In my app I want to combine a tabView with a bottom navigation bar. I want to have three tabs and three options in the bottom bar, so there should be nine different activities in the end. My tabs and the bar are defined in my activity_main.xml, so for every selected option in the bottom bar the tabs remain the same. How can I open a new fragment which depends on the combination of the selected tab and selected bottom bar option?
I suffered from a same problem before and here is my solution.
You will need 1 activity and 12 fragment not 9 to achieve it.
The main activity contains the bottom navigation bar, and inflate 3 fragment let's name them LeftFragment, MiddleFragment and RightFragment, this main activity should act only as an inflator for this fragments, don't write any other code in the activity just a manager for the bottom navigation bar.
Each one of this fragments should act as a holder or a manger for the tabs fragments, agian don't write any code in LeftFragment, MiddleFragment and RightFragment just a manager for the tablayout.
And your actual layout code should be in each tab fragment.
Hope this answer your question.

making a View like Fragment Drawer

I would like to make a Fragment show up just like a Fragment Drawer would, but not only to a list of intents.
(If you don't know what I mean by Fragment Drawer):
Google products such as Gmail, "Google app", Google Play... utilize them frequently.
The Fragment Drawer is a menu on one of these apps created by swiping from left to right or clicking the "Hamburger" button.
I would like to highlight the distinction between what I want and the Fragment Drawer is: I would like to be able to place TextViews, ImageViews, and Buttons inside of it as if it were a normal fragment in which I could just inflate a layout in it and I would rather it come from the right instead.
If a visual representation is needed I would be happy to try my hand at making one.

Categories