Android 图片水平显示 类Gallery效果

来源:互联网 发布:php microservices 编辑:程序博客网 时间:2024/05/21 06:46
 

1.HorizontalScrollView scrollView = (HorizontalScrollView) this.findViewById(R.id.scrollView); 
2.        TableRow row = (TableRow) scrollView.findViewById(R.id.row); 
3.        for (int i = 0; i < 5; i++) {  4.            ImageView imageView = new ImageView(this);  5.            imageView.setImageResource(R.drawable.k); 
6.            row.addView(imageView); 
7.        } 
8.        this.setContentView(scrollView);  布局文件

1.<?xml version="1.0" encoding="utf-8"?> 
2.<HorizontalScrollView  3.    Android:id="@+id/scrollView"  4.    xmlns:Android="http://schemas.android.com/apk/res/android"  5.    Android:layout_width="fill_parent" android:layout_height="fill_parent">  6.    <TableLayout Android:layout_width="fill_parent"  7.        Android:layout_height="fill_parent">  8.        <TableRow Android:id="@+id/row" android:layout_width="fill_parent"  9.            Android:layout_height="fill_parent" />  10.    </TableLayout>  11.</HorizontalScrollView> 

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2011-10/46084.htm

原创粉丝点击