0

画面を作りたい

2 つの固定サイズ領域: 1 つは左揃え、もう 1 つは右揃え

それらの間に、残りのすべての領域にまたがる別の領域がありますか?

プロパティで中間ビューを作成するfill_parentと、3 番目の子までのすべての領域が表示されます。

有効なプロパティは何layout_weight=0.Xですかlayout_width=20dp?

======

私はlinearLayoutを持っていorientation= horizontalます。

と の子layout_weight=0.Xlayout_width=20dpいます。

有効なプロパティは何になりますか?

4

2 に答える 2

1

LinearLayout最初の子が固定幅 (例: layout_width="20dp")、2 番目の子がゼロ以外の重み (例: layout_weight="1")、3番目の子が固定幅 (例: ) の場合、最初layout_width="20dp"の子を左に揃える必要があります。 、3 番目は右に配置され、3 番目はそれらの間の領域を埋めます。

でこれを行うことも可能ですRelativeLayoutが、上記の解決策は問題なく機能するはずなので、そのままにしておきます。

于 2013-07-29T21:30:37.577 に答える
0

次のようになります。

<LinearLayout android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="horizontal">

     <View android:id="@+id/view1"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"/>

     <View android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_weight="1"/>

     <View android:id="@+id/view3"
           android:layout_width="20dp"
           android:layout_height="wrap_content"
           android:layout_weight="0"/>

</LinearLayout>

を使用する必要がありますandroid:layout_weight

于 2013-07-29T21:33:03.310 に答える