I followed exactly this link at androidhive of simple tabs and created a tab layout with fragments of different heights. The tab layout is inside coordinator layout along with view pager. I have some textviews after the coordinator layout. And I want coordinator layout to take only space required by fragments, so that textviews is shown adjacent to even the shorter fragment. But using wrap_content in height of coordinator hides the fragments and only shows tab titles. If I set height to 1000dp, it shows both fragments but there is lot of blank space between smaller fragment and textview. How and what should I set height to get desired result?
I will paste code if required.
I currently have this situation with smaller fragment, and I want the "FOUR" to be just below "ONE" of fragment. If I set height of coordinator layout to wrap content, no fragment is shown at all.
Related
I have a Activity with 4 fragments. Each fragment consists of a listView. The bottom Fragments are not shown when the above fragments has data that fills up the screen.
Take a look at your Activity's root layout.
Your top fragment's heigh is probably match_parent.
Divide the layout on the parts you need (use layout_weight for example or height in dp) and make one below another.
This is a followup of this question where you can find all source code: Android does not show tabs
Originally I had no fragment, no tabs, just single activity that used NestedScrollView to hold its content and it worked like a charm - appbar was shortened when I scrolled and I was able to scroll the content.
Now I try to introduce tabs and I moved the content into new Fragment. I used ViewPager with layout_behavior attribute in the activity and LinearLayout in a fragment layout. I think that this is similar to CoordinatorExamples. But the content does not scroll at all and appbar is static, it does not changes when I try to scroll.
Where is the problem? The ViewPager must be OK as it works in the sample.
Is there any advantage or disadvantage to push fragments into layouts other than Frame layout ? And do you recommend any of it ?
I tried pushing fragment into Relative Layout and I saw that my fragment stays left-top of the screen but if i push it into Frame It works well. (Both height and width are match_parent in the inflated layout)
A fragment can be generally added to any ViewGroup according to the guidelines. But on the other hand the FrameLayout's documentation states that "Child views are drawn in a stack, with the most recently added child on top" which I guess is an advantage over the other ViewGroups for the fragment backstack
I wrote a FragmentActivity app with the use of the v4 support library, consisting of a fragment with a layout that contains a listview (list fragment), and a reusable fragment that changes its layout based on the list item selected (detail fragment).
In the layout for large screens, I have a fragment tag for the list fragment and a scrollview as a fragment container for the detail fragment, to allow fragments whose layouts overflow out of the screen.
Originally, for small screens, I used a basic ScrollView as the fragment container. But, since the listview in the list fragment is a scrollable fragment and there cannot be scrollable views in a ScrollView, it couldn't be scrolled; though the other fragments could be scrolled.
So, I changed the ScrollView to a FrameLayout instead, and while fragments with scrollable views can scroll, the fragments that overflowed the screen could not be scrolled.
How would I go about this problem, with the intention of enabling both fragments with scrollable views and overflowing fragments to scroll in a one-panel fragment view?
Thanks in advance
EDIT: I might be able to use ScrollView in the dynamic layouts used by the detail fragment as I see fit, using it where there are no scrollable views, but are there any better solutions?
Ok, I guess this does require the ScrollView to be used only in layouts in which there are no scrollable views.
I stopped using ScrollView as the root element in the fragment activity layout, and I manually used ScrollViews where applicable, and it's working now.
A better way is still welcome and appreciated.
I am trying to put a view horizontally on the right side of the tabs. If i put a view next to tabs, the activity displayed in tabs does not cover the region which is outside tabs thus it leaves a gap for that view. Does anyone know how to fix this.
Temporarily, I am using views instead of Tabs which made my layout very complex.