4

LinearLayout の配置に少し問題があります。

私は最初の 2 つの要素を左揃えにし、3 つ目を画面の中央に配置しようとしています。

これが私のコードです(id、text、srcから削除):

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

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </ImageView>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </TextView>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal">
        </TextView>
    </LinearLayout>
</LinearLayout>

代替テキスト http://img807.imageshack.us/img807/5953/imageg.png

これが私がやろうとしていることです。左がピンクと黄色、中央が赤です

pink = imageview
yellow = 1st texview
red = 2nd textview

何か案が ?

4

2 に答える 2

6

したがって、使用する必要のあるコードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
    <ImageView
        android:layout_width="wrap_content"
        android:id="@+id/image"    
        android:layout_height="wrap_content"/>
    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/image"/>
    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"/>
</RelativeLayout>
于 2010-08-08T08:17:59.283 に答える
1

RelativeLayoutの代わりに a を使用しLinearLayoutます。ピンクは普通の子にしてください。android:layout_toRightOfピンクの右に置くために黄色を使用してください。赤の使用がありますandroid:layout_centerHorizontal="true"

于 2010-07-25T20:21:38.837 に答える