水平横向滑动:
把GridView嵌套在HorizontalScrollView里面,跟ListView,GridView写法差不多,只是水平滑动时要设置多一些参数
1、父布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<HorizontalScrollView
android:id="@+id/horizontal_ScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:scrollbars="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<GridView
android:id="@+id/horizontal_gridview"
android:layout_width="match_parent"
android:layout_height="80dp"

本文介绍如何在Android中将GridView嵌套在HorizontalScrollView内,创建一个水平滑动的效果。通过设置相关参数,可以实现类似ListView的水平滚动体验。
最低0.47元/天 解锁文章
3138

被折叠的 条评论
为什么被折叠?



