0

この画像は、作成する必要があるものを示しています。 ここに画像の説明を入力

これは私のxmlコードです:

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

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="left" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical|center_horizontal"
    android:orientation="horizontal">
        <TextView  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:gravity="left"
            />
       <TextView
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:gravity="right"
            />
</LinearLayout>
<!-- Now the block that has to be flexible -->
<RelativeLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="15dp" 
    android:gravity="center" >
<ImageView
    android:layout_width="350dp"
    android:layout_height="wrap_content"    
    android:layout_centerHorizontal="true" >
</ImageView>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>
</RelativeLayout>
<!-- -------------------------------- -->
    <RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<ImageButton
    android:layout_width="70dp"
    android:layout_height="61dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentBottom="true"
>
</ImageButton>

<ImageButton
    android:scaleType="fitCenter"
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"  >
</ImageButton>

<ImageButton
    android:layout_width="65dp"
    android:layout_height="65dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" >
</ImageButton>

</RelativeLayout>
</LinearLayout>

ストレッチする必要があるブロックは、ImageView と TextView に含まれています。だから私の質問は - この中央のブロックを柔軟にする方法ですが、他の2つのブロックを上部と下部に保持して、画面の高さにとどまるにはどうすればよいですか? 真ん中のブロックが伸びます。

4

2 に答える 2

0

を使用しLinearLayoutます。とを に設定orientationします。中央のセクションの を正の値に設定し、固定部分の場合は、または必要に応じて値を使用します。verticallayout_heightfill_parentlayout_weight1wrap_contentdp

于 2012-04-06T21:15:30.527 に答える
0

上と下のレイアウトの場合:

android:layout_height="wrap_content" // or a value un pixels (e.g 100dp)

柔軟なレイアウトの場合:

android:layout_height="fill_parent"

相対レイアウトは必要ないことに注意してください。線形レイアウトを使用するだけで、適切に積み上げられます

于 2012-04-06T21:10:18.527 に答える