评级未在HTC中正确显示

时间:2011-05-28 12:25:05

标签: android widget rating

我正在使用样式评级小部件,它在某些设备上显示良好,但有一些设备的问题,如HTC 我的xml是:

<LinearLayout android:layout_width="fill_parent" 
            android:id="@+id/linearLayout3" 
            android:gravity="left|center_vertical|center_horizontal" 
            android:orientation="horizontal"
            android:layout_height="wrap_content">
        <RatingBar android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:numStars="5" android:stepSize="0.1"
            android:layout_weight="0.1"
            style="?android:attr/ratingBarStyleIndicator" 
            android:id="@+id/ratingbar_incident"                
            android:isIndicator="false"/>

        <TextView android:id="@+id/textViewVote" 
            android:layout_height="wrap_content" 
            android:layout_marginLeft="1dip" 
            android:textColor="@color/black" 
            android:text="(0 votes)" android:layout_width="wrap_content"/>
        </LinearLayout>

enter image description here

如何解决此问题?

1 个答案:

答案 0 :(得分:2)

首先你要注意style="?android:attr/ratingBarStyleIndicator"

The smaller RatingBar style ( ratingBarStyleSmall) and the larger indicator-only style ( ratingBarStyleIndicator ) do not support user interaction and should only be used as indicators.

另外:

When using a RatingBar that supports user interaction, placing widgets to the left or right of the RatingBar is discouraged. ``

参考:RatingBar - documentation