Gallery 的 Demo(5)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:34 点击:次
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView image = new ImageView(mContext);
image.setImageResource(mThumbIds[position]);
image.setAdjustViewBounds(true);
image.setLayoutParams(new Gallery.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
return image;
}
}
private Integer[] mThumbIds = { R.drawable.icon01, R.drawable.icon02,
R.drawable.icon03, R.drawable.icon04, R.drawable.icon05 };
private Integer[] mImageIds = { R.drawable.icon01, R.drawable.icon02,
R.drawable.icon03, R.drawable.icon04, R.drawable.icon05 };
@Override
public View makeView() {
ImageView image = new ImageView(this);
image.setMinimumHeight(200);
image.setMinimumWidth(200);
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
image.setLayoutParams(new ImageSwitcher.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
return image;
}
}
4、GridView 的 Demo
gridview.xml
代码
<?xml version="1.0" encoding="utf-8"?>
<!--
GridView - 网格控件
numColumns="auto_fit" - 列数自适应
stretchMode - 缩放模式(stretchMode="columnWidth" - 缩放与列宽大小同步)
-->
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView" android:layout_width="fill_parent"
相关新闻>>
- 发表评论
-
- 最新评论 更多>>