Android 如何在行gridview中设置两个图像?
我对gridview有问题 我在网格视图的一行中设置了两个图像。 但随着设备分辨率的变化,图像之间的空间也会发生变化。 而在风景模式下,它是可怕的 我想让我的左图像拍摄屏幕的左半部,右半部图像拍摄右半部 这是我的gridview代码Android 如何在行gridview中设置两个图像?,android,android-layout,gridview,Android,Android Layout,Gridview,我对gridview有问题 我在网格视图的一行中设置了两个图像。 但随着设备分辨率的变化,图像之间的空间也会发生变化。 而在风景模式下,它是可怕的 我想让我的左图像拍摄屏幕的左半部,右半部图像拍摄右半部 这是我的gridview代码 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:lay
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
tools:ignore="UseCompoundDrawables" >
<ImageView
android:id="@+id/grid_image"
android:layout_width="142dp"
android:layout_height="142dp"
android:scaleType="fitCenter"
android:layout_gravity="center">
</ImageView>
<TextView
android:id="@+id/grid_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@android:color/white"
android:background="#55000000"
android:gravity="center" >
</TextView>
</FrameLayout>
这是我展示图片的主要活动
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000020" >
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"
android:gravity="center"
android:columnWidth="150dp"
android:stretchMode="columnWidth" />
</RelativeLayout>
请尽快帮助我。尝试将android:numColumns=2更改为android:numColumns=auto-fit实际上我只需要两张图片。主要的问题是在半屏幕上显示图像,当您在xml中将宽度设置为142dp,并在横向模式下查看时,您希望看到什么?试试看,谢谢。。。将imageView比例类型更改为fitXY并将宽度设置为match_父项效果良好。