如何水平对齐三个imageview,如图像http://imgur.com/isvfTqZ如何进行此类型布局。它是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>
答案 0 :(得分:0)
使用OrientLayout且orientation = horizontal
答案 1 :(得分:-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>
答案 2 :(得分:-1)
如果要使用相对布局,请使用android:layout_toLeftOf =“+ @ id / img1”或android:layout_toRightOf =“+ @ id / img1”的属性。否则可以使用LinearLayout。