我最近一直在为我的学校开发一个应用程序,并想在可能发布之前对其进行清理。在应用程序的调度部分,我有 5 个按钮,它们同时在屏幕上的 ListView 上执行操作。但是,当我在屏幕上有大约 6 个或更多事件时,我会遇到问题,因为一旦列表视图接管屏幕并将按钮推离屏幕,我就无法删除事件、创建新事件等等在。
我尝试将列表视图设置为适用于正常屏幕方向的静态大小(400 像素),但如果手机设置为横向视图,您也看不到按钮。使用我当前的代码,它似乎可以在 XML 查看器中工作,但实际上并非如此。
这是没有静态大小设置的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#551A8B"
android:textColor="#FFD700"
>
<Button android:text="@string/New"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button3">
</Button>
<Button android:text="@string/Edit"
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button3"
android:layout_alignTop="@id/button3">
</Button>
<Button android:text="@string/delete"
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button4"
android:layout_alignTop="@id/button4">
</Button>
<Button android:layout_height="wrap_content"
android:id="@+id/button7"
android:layout_width="wrap_content"
android:text="@string/Previousweek"
android:layout_below="@id/button3">
</Button>
<Button android:layout_height="wrap_content"
android:id="@+id/button6"
android:layout_width="wrap_content"
android:text="@string/Next"
android:layout_below = "@id/button3"
android:layout_toRightOf = "@id/button7">
</Button>
<ListView android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFD700"
android:layout_below="@id/button7"
android:textSize="10sp" >
</ListView>
</RelativeLayout>
此代码的 XML 查看器是:
这会让我相信它会正常工作。我在模拟器上对其进行了测试,但是在输入了一堆愚蠢的事件后得到了以下结果:
这个结果与模拟器的多个版本一致。
如何在不使用导致横向问题的静态尺寸约束的情况下解决此问题?