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.
Related
I have an activity that hosts 2 fragments, I am currently using a coordinator layout in both fragments with appbarlayout and toolbar layout, I have set it up this way to scroll the toolbar off screen with my recyclerview. This has been causing my layout issues as I've posted here So I am looking to change my approach. If I can the activity will host the tool bar/app bar layout in a coordinator layout.
The problem with this approach is that the 2 fragments have recyclerviews with views at the bottom (buttons). So I'm wondering if it's possible to transfer the scroll from the fragment recyclerview by setting the appbehaviour while maintaining the position of the buttons on the bottom?
Any help on this would be appreciated as I've spent days trying to figure out the alternative approach linked above.
Thanks
Yes it's possible, I'm doing this in an activity with a ViewPager, you just need to add
app:layout_behavior="#string/appbar_scrolling_view_behavior"
in the layout that holds the fragments (in my case the viewpager)
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.
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.
I have an activity layout in which I have a viewpager that contains a couple of fragments. One of the fragment holds a listview (image sample attached).
What I'm trying to do is to scroll the listview and stick the TabStrip to the top of the layout, so when you are scrolling the list, the viewpager's fragment titles are always visible but you can see the entire listview content.
Above the viewpager there are views that needs to scroll up when the listview is scrolling.
Is any way to achieve this?
I've tried with scrollview and placing the viewpager inside it, but it doesn't work because the viewpager doesn't display at all.
Please help!
i've found the solution by using this nice library from github!!!
noties/Scrollable
I have a ViewPager with a FragmentPagerAdapter. My customer wants me to switch from ViewPager to list; a vertical list with all the fragments.
There can be a lot of fragments, so adding them all in a ScrollView is out of the question.
Can I somehow do this while still using a FragmentPagerAdapter? Adding fragments to, for example, the views in a recyclerview is not a good idea, I suppose?
What might be a good solution? I'm afraid I will have to stop using fragments for this altogether, but there is a lot of controller code in these fragments.
Do not use any fragments on any recycling views like list view, recycler view etc. Fragments are attached to its container, in recycler view container will be changed frequently, as it is getting recycled. It will trouble later.
Better you can change the view pager to vertical scrolling view pager.
You can refer link to make it vertical scrolling.