不在xml中设置布局,在代码中直接写个布局,显示下载的图片,如下图所示,图片有点丑

XML中添加个linearLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="九宫格显示图片" />
<LinearLayout
android:id="@+id/report_photo_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:orientation="vertical"
android:layout_below="@+id/text"/>
</RelativeLayout>
另外加个布局,显示图片view_files_image.xm

这篇博客介绍如何在Android应用中不依赖XML布局,而是通过代码动态创建一个九宫格来展示下载的图片。内容包括LinearLayout的使用、图片View的加载以及其他必要的配置,如在AndroidManifest.xml中的声明。
最低0.47元/天 解锁文章
561





