I am working on a feature for one of the project, where i have a image in the ListView header, And the content bottom to the Header. When i force scroll the ListView, though there is not space to scroll, i need to increase the height of the header so that it displays the bottom part of the image in the header view, when i release the scroll, the scroll should go to the actual height where it is earlier. Can you please help me on this on how to do, i am trying multiple approaches but not getting the expected behavior.
Related
I have a TabLayout inside a CoordinatorLayout set up using ViewPager.
In the first fragment I have a GridView inside a SwipeRefreshLayout. I have set the nested scrolling on for GridView using gridView.setNestedScrollingEnabled(true);
It works fine for API level 21 and above. Now for API level 19 i expect the app bar to not collapse but at least the GridView should be scrollable till the end row.
Instead what's happening is the bottom most row is not fully display, i.e. can't scroll till the bottom of gridview. And the height that's cut off(not scrollable) at the bottom row is visually the same height as that of the app bar.
My understanding is, if the nested view cannot be scrolled then it should just take the remaining height i.e. fill_parent, although even setting that to gridview doesn't help.
I've tried all possible permutations of setting layout heights but couldn't get it working. Could someone please guide me further?
I have a listView that is populate via a RSS feed. The height of each item on the ListView can vary depending on the length on the content. Is there a way to only add enough items to the listView to fill the screen (the listView has a fixed height).
For example if each item only has one line of text I can fit 7, but if they have two lines of text I can only fit 5. I want to be able to programmatically decide when to stop adding items. I don't want the ListView to have to scroll.
EDIT
Let me rephrase. I don't want to just solve it but scrolling down. There may at some point in the development be content that gets added below the screen and requires scrolling but even in that case I don't want half an item showing at the bottom. Basically I don't want broken/half items showing at the bottom, if it's on the screen it should be the whole item that is showing. If not it should be below the bottom of screen.
Try using a normal Linear Layout and when adding the inflated row, override the onMeasure to know if it fits on the screen.
I have a long list with a big header and footer and I need to scroll the list all the way down and show the whole footer.
Also, items can have very different height so the overall height cannot be simply calculated height * no items.
All the existing questions I've seen do not take in account the footer might be big and not entirely shown when scrolling to last position.
So far I've tried:
1) the simplest solution:
lv.setSelection(lv.getCount() - 1);
However this will not show the whole footer, only part of it and I need to have it all visible.
2) using:
requestFocus();
on the footer, the main layout in it, and any elements in the footer: this changes the focus but doesn't force the listview to scroll down.
3) using:
lv.scrollTo(x, y);
problem with this is that I couldn't get the real height of the listview in a reliable way as items are not fixed size.
Beside, after scrolling often part of the list is not shown leaving a wide white area.
4) header and footer are contained in two adapters but I couldn't figure out how to reach them to be shown on the screen
5) I have also tried a mixed approach:
lv.setSelection(lv.getCount() - 1);
lv.scrollListBy(mFooter.getHeight());
But the scrollListBy() doesn't seem to have any effects after a setSelection - not sure why.
Does anyone have any suggestions?
Thanks in advance
I have a layout with a linearLayout (top layout) and a listview under this.
What I want to do is like the phone app in Lollipop:
With the scrollbar I can scroll the contact list (top layout doesn't move)
When scroll the list with the finger, first the top layout is scrolling and once it is not visible anymore the listview scroll. When the top layout is visible the scrollbar doesn't move.
Someone has any idea how to do this trick?
What I'm thinking :
I can add the top layout to the header of listview, but the scrollbar take count of the header. And if I scroll with the scrollbar, the top layout will scroll
Trying to set a scrollListener to the listview, and translate the top view, but don't think it will be good and the scrollY is not available for listView
I think I can do something with a scrollView for the root layout, but I know it is not good to put a listview inside a scrollview.
I don't find any proper way to do this kind of feature...
EDIT: To be more clear, I want to translate the listview before I'm able to scroll the listview itself. Problem is when translate listview, the listview height will not expand.
I am also getting this problem in version 5.1 in lower version it's working fine.Try to use in 5.0 As it STABLE verson, also check another scrolling bug in 5.1 in this link here I could not comment so posting this as answer.
When I put a HorizontalScrollView around a GridView, the GridView gets compressed into a small column on the left. The Gridview's vertical scrollbar even appears on the left. The HorizontalScrollView's width is set to fill_parent and the GridView is also fill_parent. I don't know why this is happening.
I tried setting the GridView's visibility to GONE and VISIBILE like someone recommended but it doesn't do anything. However if fastScroll is enabled on the GridView, then dragging the fast scroll tab vertically causes the GridView to expand horizontally and it keeps expanding past the last column.
I understand now why this cannot be done. There should be a way to force the GridView to load all horizontal items and allow horizontal scrolling.
The better choice would be for them to implement some kind of DataGrid control. Most people are under the impression that GridView like a DataGrid.