画面に 2 つの要素があり、1 つは固定サイズで、もう 1 つはその上にあり、画面を埋める必要があるアクティビティを作成したいと考えています。
レイアウトでそれを行うにはどうすればよいですか?
ありがとうございました
以下のコードを使用します。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="@string/hello_world" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="test" />
</LinearLayout>
これを最初の要素に追加します。
android:layout_weight="0.8"
そして2つ目は
android:layout_weight="0.2"
次の例のように相対レイアウトを使用できます
<//you are second element
android:id="@+id/ui_radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:clickable="false"
android:orientation="horizontal" >
<///you are second element>
<//you are First element
android:id="@+id/ui_pager"
android:layout_width="wrap_content"
android:layout_above="@id/ui_radiogroup"
android:layout_height="wrap_content"
android:scrollbars="horizontal" />
その他のオプションは、要件に応じて、線形レイアウトを使用して各要素に android:layout_weight を割り当てます