我希望我的主菜单是图标的 GridView - 具体来说是 6 个图标。
当手机处于纵向布局时,我希望它们处于 2 列中,当它处于水平布局时 - 3 列 --- 已经将其排序。
我没有理清的是如何使它们仅占据整个屏幕。
适合屏幕宽度不是问题 -适合屏幕高度让我绊倒。
我希望它根据屏幕尺寸拉伸/缩小我的单元格。我曾尝试计算屏幕高度并将其除以 3 - 但存在某些问题,我认为这不是最优雅的解决方案。
所以基本上我如何用两列(3行)的gridview占据我的屏幕(比如纵向布局)?是否有任何 xml 属性可以帮助我?
这是我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:gravity="center"
/>