Android 图片水平显示 类Gallery效果
Android 图片水平显示 类Gallery效果
- HorizontalScrollView scrollView = (HorizontalScrollView) this.findViewById(R.id.scrollView);
- TableRow row = (TableRow) scrollView.findViewById(R.id.row);
- for (int i = 0; i < 5; i++) {
- ImageView imageView = new ImageView(this);
- imageView.setImageResource(R.drawable.k);
- row.addView(imageView);
- }
- this.setContentView(scrollView);
布局文件
- <?xml version="1.0" encoding="utf-8"?>
- <HorizontalScrollView
- Android:id="@+id/scrollView"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TableLayout android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TableRow android:id="@+id/row" android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
- </TableLayout>
- </HorizontalScrollView>
评论暂时关闭