使用android studio时在gridView中随意出现的图像
我最近开始在Studio上进行android开发,并尝试构建一个应用程序,在该应用程序中,我使用相机单击一张图片,并将其显示在该应用程序的图库中。这是一个基本的场景,就像现在所有的照片应用程序一样——一个摄像头和一个图库来显示应用程序本身点击的照片 我已经成功地集成了摄像头,现在正在进行画廊部分的工作。我使用grid view来制作画廊活动的布局,但效果不太好,因为图像的显示有点杂乱无章 下面是我的“GridViewAdapter.java”代码- 我已注释掉image.setLayoutParams()行,因为它导致我的应用程序崩溃。 这是相应的.xml文件-使用android studio时在gridView中随意出现的图像,android,android-layout,android-studio,gridview,gallery,Android,Android Layout,Android Studio,Gridview,Gallery,我最近开始在Studio上进行android开发,并尝试构建一个应用程序,在该应用程序中,我使用相机单击一张图片,并将其显示在该应用程序的图库中。这是一个基本的场景,就像现在所有的照片应用程序一样——一个摄像头和一个图库来显示应用程序本身点击的照片 我已经成功地集成了摄像头,现在正在进行画廊部分的工作。我使用grid view来制作画廊活动的布局,但效果不太好,因为图像的显示有点杂乱无章 下面是我的“GridViewAdapter.java”代码- 我已注释掉image.setLayoutPar
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip" >
<GridView
android:id="@+id/gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:numColumns="3"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="spacingWidthUniform"
android:gravity="center"/>
</RelativeLayout>
我得到的结果是-
我这周才开始开发应用程序,所以我非常感谢这里提供的任何帮助
多谢各位
编辑
下面是“grid\u item\u layout.xml”的代码-
试试这个。
试试这个。请添加grid\u item\u layout.xml源代码alsoDone@rahulkumarp请添加grid\u item\u layout.xml源代码alsoDone@RahulKumarThanks@RahulKumar,这让它变得完美:)谢谢@RahulKumar,这让它变得完美:)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip" >
<GridView
android:id="@+id/gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:numColumns="3"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="spacingWidthUniform"
android:gravity="center"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip" >
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/image" />
</RelativeLayout>
<GridView
android:id="@+id/gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:numColumns="3"/>