0

I want to create header like this image http://imgur.com/XrLXb0L

But my screen look like this
http://imgur.com/Ut4Eryl

How I will add 2 images one to the left and one to the right of the header???

Here is my code:

          <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>
4

3 回答 3

0

<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>

于 2013-08-20T07:19:57.590 回答
0

在 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" />
于 2013-08-20T07:22:35.183 回答
0

这是您期望的代码...

   <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>
于 2013-08-20T07:28:05.630 回答