2

親 LinearLayout に含まれる LinearLayouts を等間隔に配置しました。これは、weightSum および layout_weight パラメーターを使用して簡単に行うことができます。間隔をあけた要素を正方形にすることを受け入れると、良い結果が得られます。高さを均等に配置した後の幅がどうなるかを強制するにはどうすればよいですか?

含まれている 4 つの要素の重みを 10 に設定し、スペーサーの重みを 1 にしました (合計の重みの合計は 45 です)。

どうもありがとう!これはしばらくの間私を悩ませてきました。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rlRaces"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="45" >

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1" >
</LinearLayout>

<include
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="10"
    layout="@layout/races_badge" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

</LinearLayout>

<include
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="10"
    layout="@layout/races_badge" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

</LinearLayout>

<include
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="10"
    layout="@layout/races_badge" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

</LinearLayout>

<include
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="10"
    layout="@layout/races_badge" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

</LinearLayout>

4

0 に答える 0