<?xml version="1.0" encoding="utf-8"?>
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:columnWidth="90dp"
android:stretchMode="columnWidth"
android:gravity="center"></GridView>
<!--numColumns 每行的数量 -->
<!--verticalSpacing 高 间距 -->
<!--horizontalSpacing 宽 间距 -->
<!--columnWidth 列宽 -->
<!--gravity 位置 -->
<!--stretchMode 缩放模式 -->
import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
public class mainActivity extends Activity {
GridView gv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gv = (GridView) findViewById(R.id.gv);
gv.setAdapter(new imgadapter(this));
//imgadapter 继承至baseadapter
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。