私は最近、学校向けのアプリに取り組んでおり、公開する前に少しクリーンアップしたいと考えていました。アプリのスケジューリング部分には、同時に画面上にある ListView でアクションを実行する 5 つのボタンがあります。ただし、リストビューが画面を引き継いでボタンを画面から押し出すと、画面に約6つ以上のイベントがある場合に問題が発生し、イベントを削除したり、新しいイベントを作成したりできなくなります。の上。
リストビューを通常の画面の向きで機能する静的サイズ (400px) に設定しようとしましたが、電話が横向きに設定されている場合、ボタンも表示されません。私の現在のコードでは、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 ビューアは次のとおりです。
それはそれがうまくいくと私に信じさせるでしょう。エミュレーターでテストしたところ、ばかげたイベントをたくさん入力した後、次の結果が得られました。
この結果は、エミュレータの複数のバージョンと一致しています。
横向きの問題を引き起こす静的サイズの制約を使用せずに、この問題を解決するにはどうすればよいですか?