Android 疯狂评级棒

Android 疯狂评级棒,android,Android,我正试着玩弄一个评级条,但确实出了问题 <?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_con

我正试着玩弄一个评级条,但确实出了问题

<?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。这将产生一个带有白色矩形的黑色视图(我可能会加上一个不小的矩形)。发生了什么事

以下是一个屏幕截图:


布局编辑器就是这样显示它们的。它坏了。您可以在初始化分级栏的位置显示代码吗?

尝试将
线性布局的
android:layout\u width=“fill\u parent”
更改为
“wrap\u content”

根据我的经验,预览窗口不是很可靠,它在设备/仿真器上看起来像吗?啊,它在仿真器上看起来是正确的。但是,有20颗星,而不是像我指定的那样只有5颗星。如果我将数字设置为高于20,它将增长,但如果我将数字设置为低于20,它仍将显示20。我没有任何Java代码。此时,我只使用XML中的RatingBar标记将其显示在屏幕上。它在emulator中看起来不错,但是有20颗星,尽管我已经指定了5颗星。我怀疑星的数量在small样式的文件中,并且正在覆盖我的指定5?我怎样才能避开这件事?