如何制作更小的 RatingBar? [英] How to make a smaller RatingBar?
问题描述
我在布局中添加了 RatingBar:
<RatingBar
android:id="@+id/ratingbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="1.0"
/>
但是评分栏的默认样式太大了.
我尝试通过添加 android 样式来更改它:style="?android:attr/ratingBarStyleSmall"
But the default style for the rating bar is too large.
I've try 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.
除了您已经熟悉的?android:attr/ratingBarStyleSmall
"之外,源代码还引用了样式?android:attr/ratingBarStyleIndicator
".ratingBarStyleIndicator
稍微小一些,但仍然很丑,评论指出这些样式不支持交互".
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/pretty-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.)
祝你好运!
附言抱歉,本打算发布一个源链接供您浏览,但我是新用户,不能发布超过 1 个 URL.如果你在源树中挖掘自己的方式,它位于 frameworks/base/core/java/android/widget/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
这篇关于如何制作更小的 RatingBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!