LinearLayout中心

PoZ*_*ZyX 4 android center android-linearlayout

我在LinearLayout中遇到了一些问题.

我试图让第四个元素与左对齐,第三个元素在屏幕的中心.

这是我的代码(从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>
Run Code Online (Sandbox Code Playgroud)

alt text http://img807.imageshack.us/img807/5953/imageg.png

这是我正在尝试做的事情,左边是粉红色和黄色,中间是红色

pink = imageview
yellow = 1st texview
red = 2nd textview
Run Code Online (Sandbox Code Playgroud)

任何的想法 ?

Jaa*_*apH 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>
Run Code Online (Sandbox Code Playgroud)