简体   繁体   English

Android评分栏仅显示一星

[英]Android Rating bar displays only one star

I have created custom style for RatingBar and when I apply my style to rating bar, it shows only one star, and in properties of RatingBar , I've define the size of the start which 5 as well, but on run time it displays only one star. 我为RatingBar创建了自定义样式,将样式应用于评级栏时,它仅显示一颗星,并且在RatingBar的属性中,我还定义了起点的大小,即5,但是在运行时仅显示一星。 Note:I am using ActionbarActivity , in that I am displaying RatingBar , but when I use only Activity class, it displays 5 star and the theme is also applied on that. 注意:我正在使用ActionbarActivity ,因为我正在显示RatingBar ,但是当我仅使用Activity类时,它将显示5星,并且主题也适用于此 So Please help me out from this issue. 所以请帮我解决这个问题。

check if you are using Vector Drawable which is causing this issue. 检查是否使用Vector Drawable导致此问题。 So to work with it try to replace Vector Drawable with png image in the drawable folder and see the magic it work. 因此,要使用它,请尝试在drawable文件夹中将Vector Drawable替换为png图像,然后看看它的作用。

you are using Vector Drawable with layer-list so your Vector Drawable image is fit to the whole layout try to replace it with png which will solve your problem. 您正在使用Vector Drawable和layer-list,因此您的Vector Drawable图像适合整个布局,请尝试用png替换它,这将解决您的问题。

Try this in XML: 尝试使用XML:

<RatingBar
   android:id="@+id/rating_bar"
   style="?android:attr/ratingBarStyleSmall"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:rating="3.5" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM