如何使一个较小的RatingBar?较小、RatingBar

2023-09-12 06:51:16 作者:余生愛浪

我已经在布局中添加了的RatingBar:

I've added a RatingBar in a layout :

<RatingBar android:id="@+id/ratingbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="5"
            android:stepSize="1.0"
            ></RatingBar>   

但对于等级栏中的默认样式太大。 我有线索,加入了Android的风格来改变它:风格=机器人:ATTR / ratingBarStyleSmall

But the default style for the rating bar is too large. I've trie to change it by adding the android style : style="?android:attr/ratingBarStyleSmall"

但结果是太小了,这是不可能的设置率这个属性。

But the result is too small and it's impossible to set a rate with this property.

我怎么能这样做?

推荐答案

默认的RatingBar部件是八九不离十'跛脚。

The default RatingBar widget is sorta' lame.

该人士提及式安卓?ATTR / ratingBarStyleIndicator 除了安卓?ATTR / ratingBarStyleSmall 你已经很熟悉了。 ratingBarStyleIndicator 是稍微小一些,但它仍然是pretty的丑陋的评论指出,这些风格不支持互动。

The source makes reference to style "?android:attr/ratingBarStyleIndicator" in addition to the "?android:attr/ratingBarStyleSmall" that you're already familiar with. ratingBarStyleIndicator is slightly smaller but it's still pretty ugly and the comments note that these styles "don't support interaction".

你可能会更好过滚动您自己。有在http://kozyr.zydako.net/2010/05/23/$p$ptty-ratingbar/展示了如何做到这一点。 (我没有做我自己还,但将尝试在一天左右。)

You're probably better-off rolling your own. There's a decent-looking guide at http://kozyr.zydako.net/2010/05/23/pretty-ratingbar/ showing how to do this. (I haven't done it myself yet, but will be attempting in a day or so.)

祝你好运!

P.S。对不起,要发布一个链接到源,为您在闲逛,但我是一个新用户,不能发布超过1 URL。如果你是通过源代码树掏自己的方式,它位于框架/基/核心/爪哇/安卓/空间/ RatingBar.java

p.s. Sorry, was going to post a link to the source for you to poke around in but I'm a new user and can't post more than 1 URL. If you dig your way through the source tree, it's located at frameworks/base/core/java/android/widget/RatingBar.java