I have created a listview inside scrollview. Atfirst it was not scrolling but when it started scrolling then layouts below list view started disappearing from screen. is there any solution to dynamically calculated he height of list view and assign it or is it possible that some how the scrolling of listvew is disabled so that only its items appear on screen like normal layouts or any tags and it does not scrolls???
ListView is deprecated. I would suggest you to use RecyclerView and add nestedScrollingEnabled="true" to your xml or call RecyclerView.setNestedScrollEnabled(true) if you want to wrap adapterview with a scroller. You can also try NestedScrollView for support compability.
Good luck
Related
I have an android layout setup where I have a ScrollView with some elements and inside that I have a ListView. I am using StackOverflow's answer Android list view inside a scroll view for achieving this feature and it's working fine. My ListView is below some elements like TextView, ImageView. Problem is that when the page is presented ListView get scrolled automatically so that first item in listView is at the top (ie whole scrollview gets scrolled to present listview first item). How can I avoid this auto scrolling?
Add android:descendantFocusability="blocksDescendants" to child of SrollView (and parent of ListView)
I'm working on custom app for TV platform.
I need a something similar to grid view but much advanced in my app.
I need each row to be independent and to scroll independetly from others.
So I have created normal vertical ListView...and in each row I have custom horizontal list view...
Now I have the problem that my horizontal list views element can get focus from vertical list view.
Vertical list view doesn't need to be clickable, it just needs to scroll up and down and give focus to horizontal rows.
In horizontal list view elements I have the real content which is focusable and clickable..
I have tried with different paremeters setFocusable, setClicable, setFocusableInTouchMode, setDescendantFocusability...
But nothing worked, I can't get focus on horizontal list.
Also I'm not using touch events, but remote controller.
Tnx in advance!
try to override dispatchTouchEvent or onInterceptTouchEvent
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
What I'm trying to do is to have horizontal ViewFlipper and Listview, both with custom ArrayAdapters, inside LinearLayout which would be vertically scrollable on whole screen.
1) Tried adding ViewFlipper as a ListView header but then I can't use GestureListener since ArrayAdapter takes control over it like it's ListView item.
2) Tried putting them together inside LinearLayout but ViewFlipper's position is fixed and ListView is scrollable inside rest of the screen.
3) Trying with MergeAdapter but it can't handle swipe gesture on it's first element (ViewFlipper), it always returns ViewFlipper's item position.
Here's the picture to clarify what I'm trying to make. Top Stories is ViewFlipper and Latest Posts is ListView. And they both scroll vertically. Ignore bottom tabs and ActionBar as they are static (nonscrollable).
You've got your work cut out for you.
Here are two approaches:
1) Set the view flipper as the first row in the List view. Its a special case. Not as a header, but as a regular row.
2) Use a scroll view, and do not use the list view at all. You may have performance problems if your data for the list view is a large number of items.
Take a look at the ViewPager from the Android Compatibility Library it does what you need
I have a need for both horizontal and vertical scrolling of some data in my app. I've overridden HorizontalScrollView and I've allowed it to take an Adapter to populate its data. It behaves much like a horizontal ListView would behave, except I'm not doing any view recycling. Each item in my custom HorizontalScrollView is a ListView whose items are also populated with an Adapter. Each item in the ListView is a complex view.
I'm able to scroll horizontally, and vertically just fine except that it's performance is a bit chunky. The getView() method in the adapter for populating the custom HorizontalScrollView is only called when the Adapter is first set on the view. However, I noticed that getView() is constantly being called for the ListViews in the HorizontalScrollView. I'm wondering is this is the performance problem?
This question points out a supposed documentation bug pertaining to using a ListView inside of a HorizontalScrollView, but the same warning is not given in the documentation for the vertically scrolling ScrollView documentation.
Will I have performance issues if I put ScrollViews inside of the HorizontalScrollView?
Giving the ListView a dip value for layout_height did the trick. Not setting a height was causing the ListView to keep measuring, calling getView, etc.