android 图片水平显示,类Gallery效果

来源:互联网 发布:python 日志收集系统 编辑:程序博客网 时间:2024/05/22 10:23
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"?><HorizontalScrollViewandroid:id="@+id/scrollView"xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="fill_parent"        android:scrollbars="none"><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>



原创粉丝点击