【发布时间】:2023-03-22 11:55:01
【问题描述】:
我有以下布局文件,它后面有一个GridView 和一个ImageView 作为背景。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginRight="-70dp"
android:layout_marginBottom="-50dp"
android:src="@drawable/s_background"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"/>
</LinearLayout>
</FrameLayout>
这是我在网格的每个“单元格”中用于实际项目的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/cardInGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:singleLine="true"
android:textSize="40sp"
android:textColor="#660099"
android:typeface="serif"/>
</LinearLayout>
我现在在我的设备上看到以下内容:
有没有什么办法可以让 GridView 中的每个项目都变大,使其适合屏幕的大小,并且我在显示屏底部没有未使用的空白?
这在模拟器上运行良好,但在设备上屏幕分辨率更高,因此底部有空白。
非常感谢
【问题讨论】:
-
有趣的是,如果我将
android:minSdkVersion设置为任何值,例如 6/7/8,我就会得到上述行为。在我完全删除它的那一刻,gridview 会填满更多的屏幕空间。有什么想法吗? -
Esley 你有关于 Gridview 的任何解决方案吗?我也面临同样的问题...
-
@parag : 你能帮我解决这个问题吗........
-
@parag : 如何强制我的网格布局覆盖整个屏幕.....请帮帮我?
-
@ShahzadImam 在项目中设置背景图片
标签: android gridview android-2.1-eclair android-2.0-eclair