我想创建这样的标题https://i.stack.imgur.com/9TBD8.jpg
但我的屏幕是这样的
http://imgur.com/Ut4Eryl
我将如何添加两个图像,一个在页眉的左侧,一个到页眉的右侧???
这是我的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/border" >
<ImageView
android:id="@+id/test_button_image"
android:layout_width="wrap_content"
android:paddingLeft="5dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingTop="10dp"
android:src="@drawable/icon" >
</ImageView>
<TextView
android:id="@+id/test_button_text2"
android:layout_width="wrap_content"
android:paddingTop="10dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/test_button_image"
android:paddingLeft="10dp"
android:layout_toRightOf="@+id/test_button_image"
android:text="San Diego Unified"
android:textColor="#000000"
android:textSize="25sp" >
</TextView>
<TextView
android:id="@+id/test_button_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:layout_alignLeft="@+id/test_button_text2"
android:layout_below="@+id/test_button_text2"
android:paddingBottom="10dp"
android:text="School District"
android:textColor="#000000" >
</TextView>
</RelativeLayout>
</LinearLayout>
以下是您期望的代码。。。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:background="@drawable/border"
>
<ImageView
android:id="@+id/test_button_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/lefticon"
>
</ImageView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center"
>
<TextView
android:id="@+id/test_button_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="San Diego Unified"
android:textColor="#000000"
android:textSize="25sp" >
</TextView>
<TextView
android:id="@+id/test_button_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="School District"
android:textColor="#000000" >
</TextView>
</LinearLayout>
<ImageView
android:id="@+id/test_button_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/righticon" >
</ImageView>
</LinearLayout>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/firstImage" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/test_button_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:src="@drawable/icon" >
</ImageView>
<TextView
android:id="@+id/test_button_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/test_button_image"
android:layout_toRightOf="@+id/test_button_image"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:text="San Diego Unified"
android:textColor="#000000"
android:textSize="25sp" >
</TextView>
<TextView
android:id="@+id/test_button_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/test_button_text2"
android:layout_below="@+id/test_button_text2"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:text="School District"
android:textColor="#000000" >
</TextView>
</RelativeLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/secondImage" />
</LinearLayout>
在RelativeLayout:中这样尝试
<ImageView
android:id="@+id/test_button_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/test_button_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/test_button_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/test_button_image2"
android:text="San Diego Unified"
android:textColor="#000000"
android:textSize="25sp" />
<TextView
android:id="@+id/test_button_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/test_button_text2"
android:layout_below="@+id/test_button_text2"
android:text="School District"
android:textColor="#000000" />