问题
I have this type of layout
<LinearLayout>
<ScrollView>
<LinearLayout>
<ImageView/>
<button>
<ListView>
</LinearLayout>
</ScrollView>
So in this Case my List view Scrolling not happens and my View Scrolling is perform i want also perform Listview Scrolling when data is more. and List view is need to put in Scroll view parent layout so how can solve this problem please help me.
回答1:
Never put a ListView
inside of a ScrollView
. Never. You have two options:
If you don't necessarily want the
ImageView
andButton
to scroll away, just remove theScrollView
:<LinearLayout android:orientation="vertical" ...> <ImageView .../> <Button .../> <ListView .../> </LinearLayout>
This one is slightly more complicated. Implement a custom list adapter (by extending BaseAdapter, for example, or one of its subclasses) and, in your
getView
method return theImageView
and theButton
for positions 0 and 1, respectively. This way, your layout will only contain aListView
, but its first two items will be theImageView
and theButton
.
P.S.: Never put a ScrollView
in a ListView
, either.
回答2:
I don't understand for what you try to use ScrollView with ListView too? If your layout is really big than screen, then will be good to use a ScrollView like described here:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:visibility="visible">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
..your any xml data
</LinearLayout>
</ScrollView>
ListView has internal scroll tool, so you just need to choose a correct way to use it.
来源:https://stackoverflow.com/questions/7444680/androidthere-are-a-listview-in-scrollview-so-listview-scrolling-not-happend