Android list view inside a scroll view auto scroll issue - android

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)

Related

Disabling the scroll of listview

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

Android ListView with a focusable elements in a row

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

Not scrollable listview in scroll view android

i need to make a layout that is scrollable, holds a listview that is not scrollable(full height of the content). So when i scroll the content above the listview is showed, and the full listview is displayed.
Is this possible in android?
what do you mean by ListView ( not scrollable).. will it have predefined items(count) ?
you can have a <ScrollView></ScrollView> inside of which a normal(linear/relative layout say id insidelayout1)
For single item of your ListView, create a separate xml(say item.xml) and try to inflate item.xml into insideLayout1.
Will that work for you.. or detail out your requirement...
If you want to put list view inside the scroll view than you have to fix the height of list view.
otherwise you can't scroll it properly.

Merging ViewFlipper with ListView

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

Android ListView stops scrolling when inside a Scroll View

Why is it when I insert a list view into a scrollview, the list view stops scrolling.
The Scroll View scrolls normally, but the list view seems as if it is frozem
Well it seems that you must not place a list view inside a scroll view, because the system will not know which control to scroll!
There is no need to add listview in scrollview since scrolling is a default property for
ListView. That is all.
Please go through the Android documentation before design any of the UI.

Categories

Resources