2013-03-12 60 views
1

我有一個listbar的評級欄,用戶需要評分1到7的比例不同的項目(圖片)。我用一個linearviewout和imageview和ratingbar作爲我的listview的佈局。然而,由於某些未知的原因,評級欄不佔用完整的可用空間,而我的最後一顆星則顯示爲不完整。Ratingbar沒有佔用所有可用空間

enter image description here

而且我的佈局文件如下

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:minHeight="40dp" 
    android:padding="10dp" > 

    <ImageView 
     android:id="@+id/logo" 
     android:layout_width="80dp" 
     android:layout_height="match_parent" 
     android:padding="5dp" 
     android:scaleType="centerInside" /> 

    <RatingBar 
     android:id="@+id/ratingbar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" 
     android:isIndicator="false" 
     android:paddingLeft="15dp" 
     android:stepSize="1.0" > 
    </RatingBar> 

</LinearLayout> 

我設置numStars在我的代碼。如果我將numstars增加到8,同樣的事情發生,7顆星表現爲完整,最後一顆星表現爲不完整。

+0

我看不出有任何意義在這裏使用RelativeLayout,刪除它,你會沒事的。 – Egor 2013-03-12 16:05:55

+0

其實我沒有任何相關佈局,是隨機嘗試。沒有或沒有相關的佈局運氣。 – 2013-03-12 16:08:56

回答

1

填充抵消一View的內容(在你的情況下推動內容到右)等等來代替:

android:paddingLeft="15dp" 

嘗試使用:

android:layout_marginLeft="15dp" 
+0

是的,隨着setMax(7)爲我做了詭計 – 2013-03-13 10:19:35

相關問題