Android开发

3、Android高级控件的使用:

GridView的使用方法:

如果是列表(单列多行形式)的使用ListView,如果是多行多列网状形式的优先使用GridView。

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<!-- android:horizontalSpacing="10dp"水平拮据 -->
<!-- android:verticalSpacing="10dp"垂直拮据 -->

</GridView>
GirdView的一些属性:

android:numColumns="auto_fit" --------列数设置为自动
android:columnWidth="90dp",----------每列的宽度,也就是Item的宽度
android:stretchMode="columnWidth"------缩放与列宽大小同步
android:verticalSpacing="10dp"----------垂直边距
android:horizontalSpacing="10dp"-------水平边距

1、准备数据源

2、新建适配器

3、加载适配器

GridView(网格视图)是按照行列的方式来显示内容的,一般用于显示图片,图片等内容,比如实现九宫格图,用GridView是首选,也是最简单的。

posted @ 2022-04-20 20:30  萧贾jzm  阅读(8)  评论(0编辑  收藏  举报
//歌单id