アプリ用に別のランドスケープ ビュー ファイル (xml ファイル) をプログラムしようとしています。ただし、Framelayout はうまくスタックできないためandroid:layout_gravity
、x/y ディメンションを使用して割り当てる必要があります。たとえば、次のようになりますandroid:layout_gravity="center"
。この例では、何かを (垂直方向と水平方向の両方で) ちょうど中央に配置しています。
しかし、私の問題は、物を配置したい垂直面に 4 つのレベルがあることです。テキスト行、2 つのボタン (true、false) のある行、別のボタン (チート)、最後に 2 つの矢印ボタン (前と次) のある行。しかし、layout_gravity では、上、中央、下という非常に大雑把な配置しかありません。何も割り当てないと、すべて左上隅に表示されることに気付きました。
では、これらを垂直に積み重ねて、上から下まで適切な間隔で配置するにはどうすればよいでしょうか? 2 つのものに同じパラメーターを割り当てても、それらはスタックされませんが、ひどくオーバーラップします。
以下は私のコードです。そこにはまだ重力レイアウトを入れていません。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/question_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/true_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/true_button" />
<Button
android:id="@+id/false_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/false_button" />
</LinearLayout>
<Button
android:id="@+id/cheat_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cheat_button" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/prev_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_left"
android:contentDescription="@string/move_back"
/>
<ImageButton
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_right"
android:contentDescription="@string/move_forward"
/>
</LinearLayout>
</FrameLayout>