问题
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
ImageViewandButtonto 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
getViewmethod return theImageViewand theButtonfor positions 0 and 1, respectively. This way, your layout will only contain aListView, but its first two items will be theImageViewand 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