I have an activity that contains LISTVIEW with some text data and below that i had GRIDVIEW with some set of data.Now i have to scroll whole activity.
例如,如果我的列表视图包含20个文本数据,那么我无法滚动到listview之外,因此无法看到我的gridview内容。我必须滚动整个活动而不是列表或网格。
我使用了xml以下的代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sampletext.SampleText" >
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</ListView>
<GridView
android:id="@+id/gridView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/listview"
android:numColumns="3" >
</GridView>
</RelativeLayout>
答案 0 :(得分:0)
ListView和GridView都带有默认的滚动功能。我想你不能同时使用两者,更好的是你可以互相切换。您可以保留按钮或 FloatingActionButton ,然后从列表视图切换到gridview,反之亦然。如需切换,您可以参考
How to swap GridView with ListView in the same Activity with the same ArrayAdapter?