GridView完美的例子
2015-09-08 10:09
309 查看
1.主界面布局代码:activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_margin="10dp" >
<GridView
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="spacingWidthUniform" >
</GridView>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
2.主界面GridView列表子项布局文件:list_item.xml
a.包裹HorizontalScrollView控件是GirdView横向滚动的基本条件 b.GirdView外包裹LinearLayout是java代码中参数设置的必要条件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_margin="10dp" >
<GridView
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="spacingWidthUniform" >
</GridView>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
2.主界面GridView列表子项布局文件:list_item.xml
相关文章推荐
- SequenceFile在hadoop中使用
- IOS开发—Core Animation核心动画介绍
- 计算机常用网络指令
- codeforces 396A A. On Number of Decompositions into Multipliers(组合数学+数论)
- 数据结构学习之路-第三章:顺序栈
- 【Django】template中实现加减乘除数学运算[加法 减法 乘法 除法]
- SVN中检出(check out) 和 导出(export) 的区别
- PPT2010中设置音乐播放停止位置
- Eclipse中修改tomcat内存大小
- java中urlrewrite使用文档(简单demo)
- 还记得星球大战里那个圆头圆脑的机器人吗
- 根据volley网络请求框架封装好的get请求和post请求
- iOS: #ifdef DEBUG
- java访问权限
- C# Redis 系列二
- JS设计模式——外观模式
- Activiti 5.18 的Mybatis版本问题
- c++对txt文件的读取与写入
- 使用javamail收发邮件
- max_element和merge(应用于有序区间)