2013-08-20 17 views
0

添加左側和右側圖像我想這樣的形象 http://imgur.com/XrLXb0L如何在頭

創建頭,但我的屏幕看起來像這樣
http://imgur.com/Ut4Eryl

如何,我會添加2個圖像一個在左,一個在標題的右邊?

這裏是我的代碼:

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

只是通過縮進來改進對代碼的理解。 – Master

回答

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

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