[英]android ratingbar size
I have finally found out how to change images of the ratingBar, but I can't figure out how to change the size. 我终于找到了如何更改ratingBar的图像,但我无法弄清楚如何更改大小。 I have this 我有这个
<resources>
<style name="foodRatingBarSmall" parent="@android:style/Widget.RatingBar.Small">
<item name="android:progressDrawable">@drawable/rating_bar_used</item>
<item name="android:minHeight">10dip</item>
<item name="android:maxHeight">10dip</item>
</style>
</resources>
But whenever i change the size in the minHeight
and maxHeight
it remains the same. 但每当我改变minHeight
和maxHeight
的大小时,它都保持不变。
My layout xml: 我的布局xml:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:onClick="showRecipeOnClick" android:clickable="true" style="@style/row">
<TableRow
android:id="@+id/tableRow1" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center_vertical">
<TextView android:id="@+id/customName"
android:textSize="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@color/black"
android:layout_weight="5">
</TextView>
<RatingBar android:id="@+id/mainRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.5"
android:isIndicator="true"
android:layout_gravity="center_vertical"
style="@style/foodRatingBarSmall"></RatingBar>
</TableRow>
<View android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="@color/black"/>
</TableLayout>
What am I doing wrong? 我究竟做错了什么?
Thank you for your help 谢谢您的帮助
Change the Style from 从中更改样式
parent="@android:style/Widget.RatingBar.Small"
to 至
parent="@*android:style/Widget.RatingBar.Small"
For more information see the below link especially the comment from 6 onwards. 有关更多信息,请参阅以下链接,尤其是从6开始的评论。
http://code.google.com/p/android/issues/detail?id=18659 http://code.google.com/p/android/issues/detail?id=18659
A solution consists in applying the scale attribute to your RatingBar, thus it's not really precise : 解决方案包括将scale属性应用于RatingBar,因此它不是非常精确:
<RatingBar android:id="@+id/mainRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.5"
android:isIndicator="true"
android:layout_gravity="center_vertical"
style="@style/foodRatingBarSmall"
android:scaleX="0.8"
android:scaleY="0.8"></RatingBar>
Stars are smaller and interaction still works 星星较小,交互仍然有效
I am having the same weird problem when I switched from 1.6 to 2.1. 当我从1.6切换到2.1时,我遇到了同样奇怪的问题。 Remove the small word in your style and try: 删除你风格的小词并尝试:
android:style/Widget.RatingBar.Small
to 至
android:style/Widget.RatingBar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.