私の人生にとってはこれを理解できません。 (すべての利用可能なスペースを埋める)Androidレイアウトの問題
ImageViewの(等間隔) のTextView(必要に応じて垂直方向のスペースを取って) のEditText(必要に応じて垂直方向のスペースを取って) ボタンボタンボタン
:私は、次のようなレイアウトを(縦に)持ってしようとしています次のレイアウト設定があります。イメージビューは現在200dipに設定されています。利用可能なすべてのスペースを埋めるためには、この価値はどうあるべきですか?他のコンポーネントが最初に来て、画像ビューは残っているものを取得する必要があります。私はこれについての例を探し、何も見つけていない。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView android:id="@+id/imgView"
android:layout_width="fill_parent"
android:layout_height="200dip"
android:layout_alignParentTop="true" />
<TextView android:id="@+id/lblDesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/PhotoDesc"
android:layout_below="@id/imgView" />
<EditText android:id="@+id/edtDesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lblDesc" />
<!-- Bottom layout contains the three buttons - Take Photos, Transmit, and Setup. -->
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="3">
<!-- Take photos button -->
<Button android:id="@+id/btnCamera"
android:gravity="center_vertical|center_horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/TakePhotos" />
<!-- Transmit button -->
<Button android:id="@+id/btnUpload"
android:gravity="center_vertical|center_horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/Upload" />
<!-- Setup button -->
<Button android:id="@+id/btnSetup"
android:gravity="center_vertical|center_horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Setup"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
素晴らしい、一度に2つの答え!どちらも正しいですが、レイアウトの間隔がどのように分割されているかについての簡単な説明は非常に役に立ちました。私はAndroid開発の2日目にいます。私はそれを手に入れていませんでした!ありがとう! – Paul
私は2つの余分な詳細で答えを混乱させたくありませんでしたが、余分な情報が好きだったので、もう1つの興味深いヒントがあります。 LinearLayoutの子で0ディップ/ウェイトテクニックを使用すると、その子の初期測定パスはスキップされ、ウェイト測定パスにのみ依存します。 (体重のない子供は、1回のパスだけに依存します)。子供が実際に測定に時間がかかる複雑なサブ階層である場合、これは重要な最適化になります。 – adamp