2010-08-05 60 views
0

我想玩一個RatingBar,但有些東西確實是錯的。Crazy RatingBar

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    > 
    <RatingBar 
     android:id="@+id/shoppingitem_rating" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:numStars="5" 
     android:rating="0" 
     style="?android:attr/ratingBarStyleSmall" 
     /> 
</LinearLayout> 

這是我的佈局XML。這導致了一個黑色的視圖與一個白色的矩形(這是不小的,我可能會添加)。到底是怎麼回事?

下面是截圖:

screenshot

+0

根據我的經驗,預覽窗口不是很可靠,它看起來像在設備/模擬器上? – sgarman 2010-08-05 20:57:40

+0

啊,它在模擬器中看起來是正確的。但是,有20顆星,而不是像我指定的那樣只有5顆星。 – Andrew 2010-08-05 21:08:00

+0

如果我設置一個高於20的數字,它會增長,但如果我設置的數字低於20,它仍然會顯示20. – Andrew 2010-08-05 21:11:38

回答

0

這是佈局編輯器是如何顯示它們。它被破壞了。你可以在初始化評級欄的位置顯示代碼嗎?

+0

我沒有任何Java代碼。此時,我只需將XML中的RatingBar標記顯示在屏幕上即可。它在模擬器中看起來很好,但即使指定了5個,也有20顆星。 – Andrew 2010-08-05 21:20:30

+0

我懷疑星星的數量是在小樣式的文件中,並且超過了我的規格5。我怎樣才能解決這個問題? – Andrew 2010-08-05 21:30:57

1

嘗試將android:layout_width="fill_parent"LinearLayout更改爲"wrap_content"