2010-08-05 31 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"