Hi I have a problem with ListView scrolling. My activity layout:
<ScrollView>
<ReleativeLayout>
<ListView>
<... other controls>
When this list view has a lot of elements, so that they do not fit on the screen, I cannot scroll. The interesting part is that the scroll works in landscape orientation, but not in portrait.
Does any one has a suggestion on how to tweak my layout in order to allow scrolling?
Thanks
Do NOT place a listview inside a scrollview, google says it doesnt work, and every time I've tried it brings problems.
Think of this, when you swipe your finger over a the listview, what should scroll, the listview or the scrollview?
You are going to have to rethink that portion of the UI.
Related
Beneath my RecyclerView is a Button. The RecyclerView´s height is set to wrap_content, so when there are a lot of items it takes the full screen and when scrolling to the bottom the Butten is not visible.
I solved this with wrapping these two views inside a ScrollView. This works almost but when scrolling to the button and then up again the RecyclerView start to scroll first while the button is still on the screen. So I needed to disable the scrolling from the RecyclerView itself. I solved this with setting android:nestedScrollingEnabled="false"
.
This seems to work but now I have another problem. When having a lot of items the RecyclerView does not show all items only the first few items. This happens with disabling nestedScrolling, when I turn it back on it displays all items again but then I have the previously explained problem.
Any ideas what I can do?
In case anyone is having the same problem: The solution is to use NestedScrollView instead of ScrollView
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.
I have an activity which shows these three things in order.
ViewFlipper (User can fling it left/right)
EditText
ListView (List view can have n number of rows. lets limit it for 100. each row has images which get downloaded asynchronously)
I want that user can scroll vertically so I put above three item in single relative layout and that in to scrollView
<RelativeLayout>
<ScrollView>
<RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Problem with this approach
ListView and scroll view together is bad user-experience. When List will cover all screen user will have problem in scrolling complete view itself.
Solution which I could think of
Disable Scroll on ListView and let it show all items (Is this good enough)
User addHeaderView (not sure how to use it)
Second Approach (Which I did and ran into problems).
Instead of using ListView add LinearLayout (replacement of listrow) dynamically.
Problem with this approach
Lot of ugly coding as there is no sophisticated adapter for such scenarios. Need to populate each LinearLayout and it creates more issue because I have async Image loading for every LinearLayout.
What could be better approach. Any alternates?
Do not use a ScrollView and a ListView together, this is a bad thing as mentioned by Romain Guy, the creator of ListView. The problem with you LinearLayout approach is performance: you will need to create n new Views, while the ListView just reuses existing ones.
The solution I could think of (in case it is not possible to make your Layout components to fit on the screen without scrolling), you could disable scrolling in your ListView and add "scroll up" and "scroll down" buttons, setting the onClickListener and OnLongClickListener to let the user control scrolling speed. Though this might be not the best approach. Consider re-disigning your layout so the components fit on a single screen. This is usually not a good user expierince to enable scrolling because of layout components not fitting on a single screen. Your could add a page more to your ViewFlipper and place your ListView there for example
I'm trying to implement a FAQ screen in my project and I wanted to use ExpandableListView. I display question as a text in GroupView and answer as a text in ChildView. If items can fit into screen, there's no problem, it works as it should. But when there's more items than the screen height and I have to scroll, this problem occurs that when I expand the last item, it acts like it's expanded but I can not scroll to the child view.
Any ideas or experiences on this issue?
Here's the screenshot (as you can see, scrollbar shows that it's expanded and there's place to scroll, but when I try to scroll, no luck) :
EDIT: I found out that this problem is because I'm using a WebView inside child row, when I switched to TextView it works as expected. How can I achieve the same result with WebView?
In your getGroupView() method of BaseExpandableListAdapter, give view=null as the first line of the method.
I am adding a listview inside a scrollview in xml that xml(Screen) is loading from the middle screen. In my design I have a top part like a textview and a list view and middle part like editext and bottom part like button. Page is loading from the middle part. If it scrolls I can only see the above part. I want to load the page from above part. Can anybody tell me what the problem is and how to resolve it?
Thanks
Use android:fillViewport="true" as an attribute in your scrollview tag and it will fill up the screen.
Actually there is no need to use ScrollView with ListView. Use ListView only, you will be able to scroll the items in a ListView.
You should never use a ScrollView with a ListView, because ListView
takes care of its own vertical scrolling. Most importantly, doing this
defeats all of the important optimizations in ListView for dealing
with large lists, since it effectively forces the ListView to display
its entire list of items to fill up the infinite container supplied by
ScrollView.
found it here
using smoothScrollTO(0,0) to fix the issue