2012-06-27 151 views
2

How breadcrumb should look likeandroid按鈕與按鈕互相重疊

如何設置按鈕,如上圖所示。在ios中它被稱爲麪包屑風格。

我試着將按鈕放在相對佈局中,一個按鈕位於中間,另兩個位於兩側,但所有按鈕之間仍存在差距,在不同的設備中它看起來非常可怕。

以下是我的xml文件:

<RelativeLayout 
      android:id="@+id/TBtnLayout"  
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:background="@drawable/title_bar"> 
       <ImageButton 
        android:contentDescription="@string/btn_desc" 
        android:id="@+id/left_btn" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerVertical="true" 
        android:layout_toLeftOf="@+id/center_btn" 
        android:background="@drawable/s_unsel_btn"> 
       </ImageButton> 

       <ImageButton 
        android:contentDescription="@string/btn_desc" 
        android:id="@+id/center_btn" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"    
        android:layout_centerVertical="true" 
        android:layout_centerInParent="true" 
        android:background="@drawable/c_unsel_btn"> 
       </ImageButton> 

       <ImageButton 
        android:contentDescription="@string/btn_desc" 
        android:id="@+id/right_btn" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerVertical="true" 
        android:layout_toRightOf="@+id/center_btn" 
        android:background="@drawable/t_sel_btn"> 
       </ImageButton> 
     </RelativeLayout> 

回答

3

您是否嘗試過使用負保證金?例如:

<RelativeLayout 
    android:id="@+id/TBtnLayout"  
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:background="@drawable/title_bar"> 
     <ImageButton 
      android:contentDescription="@string/btn_desc" 
      android:id="@+id/left_btn" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_marginRight="-10dip" 
      android:layout_toLeftOf="@+id/center_btn" 
      android:background="@drawable/s_unsel_btn"> 
     </ImageButton> 

     <ImageButton 
      android:contentDescription="@string/btn_desc" 
      android:id="@+id/center_btn" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content"    
      android:layout_centerVertical="true" 
      android:layout_centerInParent="true" 
      android:background="@drawable/c_unsel_btn"> 
     </ImageButton> 

     <ImageButton 
      android:contentDescription="@string/btn_desc" 
      android:id="@+id/right_btn" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="-10dip" 
      android:layout_toRightOf="@+id/center_btn" 
      android:background="@drawable/t_sel_btn"> 
     </ImageButton> 
</RelativeLayout> 

您可以玩這些值,直到它適合您。