scrollview 几个grildview
时间: 2023-07-28 12:16:10 浏览: 55
可以在 ScrollView 中嵌套多个 GridView,实现多个网格布局的效果。代码示例如下:
```xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<GridView
android:id="@+id/gridview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3"/>
<GridView
android:id="@+id/gridview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"/>
<GridView
android:id="@+id/gridview3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="4"/>
</LinearLayout>
</ScrollView>
```
在代码中,我们首先创建了一个 ScrollView,然后在其中嵌套了一个 LinearLayout。在 LinearLayout 中,我们分别创建了三个 GridView,它们的布局方式可以通过设置 numColumns 属性来控制。最后将 LinearLayout 设置为 ScrollView 的子视图即可。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)