本文是小编为大家收集整理的关于listView和ScrollView的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。
问题描述
我有一个带有3个imageView的LinearLayout,垂直方向上的ListView.i希望在用户滚动列表时滚动包括图像的全屏.可以?谢谢
<?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:background="#222222" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ph2" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ph1" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ph2" /> <ListView android:id="@+id/ll4_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5" android:cacheColorHint="#00000000" /> </ScrollView>
推荐答案
您绝对不想将LISTVIEW放在滚动视图中,但它肯定可以包含图像.我建议考虑将布局与标题中的图像放入ListView.请参阅 AddHeaderview .这个相关所以post 对你来说也可以用来.
其他推荐答案
您应该搜索API,滚动视图不能是一个以上一个孩子,必须有一个直接的孩子
问题描述
I have a linearlayout with 3 imageView and a listview in vertical orientation.i want to scroll the full screen including the images when the user scrolls the list.is that possible?thanks
<?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:background="#222222" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ph2" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ph1" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ph2" /> <ListView android:id="@+id/ll4_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5" android:cacheColorHint="#00000000" /> </ScrollView>
推荐答案
You definitely don't want to put the ListView inside of the ScrollView, but it's certainly possible to include the images. I would recommend considering putting the layout with the images in a header to the ListView. See addHeaderView. This related SO post may also be of use to you.
其他推荐答案
You should search api , the scrollView can not be inner more than one child , must has one direct child