android 图片水平显示,类Gallery效果
16lz
2021-01-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>
更多相关文章
- Android动态添加布局
- 解决Android Studio XML布局格式化无法换行的问题
- 【Android】debug 状态下其签名文件 debug.keystore 相关(如何获
- Android 文件上传支持拍照录用录视频
- Android 的res/values/colors自定义颜色列表和注释表及布局文件
- 新建android project和其配置文件的基本介绍
- Android使用adb命令直接修改文件
- CrossWalk - Android 动态加载so库文件
- Android线性LinearLayout布局xml属性介绍