2015-06-19 13 views
0

這.XML將在RecycleView列表中的項目的佈局,但最後兩個按鈕覆蓋爲什麼這些ImageButtons(刪除和更新)的覆蓋

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#Ffffff" 


    android:baselineAligned="false" 
    android:weightSum="1"> 

    <LinearLayout android:id="@+id/thumbnail" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="3dip" 
     android:layout_alignParentLeft="true" 
     android:background="@drawable/favorite" 
     android:layout_marginRight="5dip"> 

     <ImageButton 
      android:id="@+id/imageButton" 
      android:layout_width="25dip" 
      android:layout_height="25dip" 
      android:background="@null" 
      android:src="@drawable/nofavorite"/> 

    </LinearLayout> 


    <TextView 
     android:id="@+id/text_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/thumbnail" 
     android:layout_toRightOf="@+id/thumbnail" 
     android:text="Rihanna Love the way lie" 
     android:textColor="#040404" 
     android:typeface="sans" 
     android:textSize="15dip" 
     android:textStyle="bold"/> 
    <TextView 
     android:id="@+id/artist" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#343434" 
     android:textSize="10dip" 
     android:layout_toRightOf="@+id/thumbnail" 
     android:text="Just gona stand there and ..." 
     android:layout_below="@+id/text_view" /> 


    <ImageButton android:layout_width="wrap_content" 
     android:id="@+id/update" 
     android:layout_height="wrap_content" 
     android:src="@drawable/nofavorite" 
     android:background="@null" 
     android:layout_alignRight="@+id/artist" /> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@null" 
     android:id="@+id/delete" 
     android:src="@drawable/favorite" 
     android:layout_alignRight="@+id/artist" 
     /> 


</RelativeLayout> 

它們應該在的結束對了,最後DELETE按鈕,在這個按鈕的左邊,但在屏幕右端的UPDATE按鈕,我會綁定一些東西這個按鈕以後

和另一個問題,我怎樣才能做一個divider btw這幾項?

謝謝你=)

回答

2

那是因爲你基本上對準2個圖像的右邊緣與ID藝術家查看的右邊緣兩個圖像使用layout_alignRight="@+id/artist"。要達到您想要的效果,請在DELETE按鈕上使用layout_alignParentRight="true",在UPDATE按鈕上使用layout_toLeftOf="@+id/delete"。順便說一句,爲什麼你需要父級的layout_weightSum。它只適用於LinearLayout。

對於項目之間進行分隔,您可以使用與左(右)邊界背景上的一個項目或把他們之間的視圖。

+0

工作就像一個魅力,謝謝 – user2582318

1

你的按鈕需要具有相對於彼此設置其位置的屬性。目前,關於其位置的唯一指示是:

android:layout_alignRight="@+id/artist" 

,由於您使用的是RelativeLayout的(好的)是不夠的,把你的組件。我建議你在IDE中使用可視化編輯器來瀏覽參數。

有一點要記住的是,在你的XML文件的最後描述的元件是應有的位置relativ屬性的其他組件之一。所以在你的情況下,你的DELETE按鈕。

+0

謝謝你,我會玩它=) – user2582318

相關問題