如何缩小Ratingbar的大小? [英] How can I decrease the size of Ratingbar?

查看:186
本文介绍了如何缩小Ratingbar的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的活动中,我有一些评分栏.但是这个酒吧的大小太大了! 如何缩小尺寸?

In my activity I have some Rating bars. But the size of this bar is so big! How can I make it smaller?

修改

感谢加百利·尼古特(Gabriel Negut), 我是按照以下样式进行的:

Thanks to Gabriel Negut, I did it with the following style:

<RatingBar
style = "?android:attr/ratingBarStyleSmall"
android:numStars = "5"
android:rating   = "4" />

现在,尺寸减小了,但是星级数和等级却没有生效!!! 为什么?我有7颗星被选中其中6颗.

Now, the size is reduced but number of stars and rating do not take effect!!! Why? I have 7 stars that 6 of them is selected.

推荐答案

我发布的原始链接现在已断开(有充分的理由说明仅发布链接不是最佳方法).您必须使用ratingBarStyleSmall或从Widget.Material.RatingBar.Small继承的自定义样式来设置RatingBar的样式(假设您在应用中使用Material Design).

The original link I posted is now broken (there's a good reason why posting links only is not the best way to go). You have to style the RatingBar with either ratingBarStyleSmall or a custom style inheriting from Widget.Material.RatingBar.Small (assuming you're using Material Design in your app).

选项1:

<RatingBar
    android:id="@+id/ratingBar"
    style="?android:attr/ratingBarStyleSmall"
    ... />

选项2:

// styles.xml
<style name="customRatingBar"   
    parent="android:style/Widget.Material.RatingBar.Small">
    ... // Additional customizations
</style>

// layout.xml
<RatingBar
    android:id="@+id/ratingBar"
    style="@style/customRatingBar"
    ... />

这篇关于如何缩小Ratingbar的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆