0

次のレイアウトを作成しようとしています。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </TextView>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </TextView>

    <SeekBar
        android:id="@+id/seekbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </TextView>

</LinearLayout>

親レイアウトの 80% を textView1 と textView2 に割り当て、SeekBar を可能な限りラップし、残りの空き領域を textView3 に割り当てたいと考えています。

私はしようとしました:

  • layout_weight 属性 (それぞれ - 4、4、1、1) を使用しますが、最後のビューは SeekBar と重なっています
  • textView1 と textView2 でのみ layout-weight を使用し、SeekBar の高さを「wrap_content」に設定し、最後のビューに「match_parent」を設定します

そして今、私にはもうアイデアがありません。そんなお悩みはありませんか?

4

1 に答える 1

0

このレイアウトを作成するには、次のようにします。

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="4" >
</TextView>

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="4" >
</TextView>

<SeekBar
    android:id="@+id/seekbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1">
</TextView>

ウェイトを変更してサイズを調整します。シーク バーでコンテンツをラップし、他のビューを重視します。

それが役立つかどうか教えてください。

于 2013-03-17T14:45:38.050 に答える