-4

我如何像这张图片一样水平对齐三个imageview http://imgur.com/isvfTqZ 如何制作这个typelayout。是linearlayout还是Relativelayout帮帮我???如何在水平方向上垂直组合 imageview 和 textview ...?

<?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="fill_parent"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="92dp"
    android:background="#F9F939"
    android:src="@drawable/ic_launcher"
    android:layout_toLeftOf ="@+id/imageView6"
    android:layout_centerInParent="true"
    android:padding="15dp" />

 <ImageView
    android:id="@+id/imageView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#54F71D"
    android:src="@drawable/ic_launcher"
    android:layout_centerInParent="true"
    android:padding="15dp"
    android:layout_margin="10dp" />

   <ImageView
    android:id="@+id/imageView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#1DF7AB"
    android:src="@drawable/ic_launcher"
    android:layout_centerInParent="true"
    android:layout_toRightOf="@+id/imageView6"
    android:padding="15dp" />



 </RelativeLayout>
4

3 回答 3

0

使用方向 = 水平的 LinearLayout

于 2013-07-29T08:50:03.630 回答
-1

你可以这样做...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:gravity="center"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@null"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="5dp"
            android:contentDescription="@null"
            android:text="@string/hello_world" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:orientation="vertical" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@null"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="5dp"
            android:contentDescription="@null"
            android:text="@string/hello_world" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imgHome2Imag3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@null"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="5dp"
            android:contentDescription="@null"
            android:text="@string/hello_world" />
    </LinearLayout>
</LinearLayout>
于 2013-07-29T08:57:28.167 回答
-1

如果要使用相对布局,请使用 android:layout_toLeftOf="+@id/img1" 或 android:layout_toRightOf="+@id/img1" 的属性。否则可以使用 LinearLayout。

于 2013-07-29T09:01:49.540 回答