我终于找到了如何更改ratingBar的图像,但我无法弄清楚如何更改大小.我有这个
<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>
Run Code Online (Sandbox Code Playgroud)
但每当我改变它的大小minHeight,maxHeight它仍然是相同的.
我的布局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>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
谢谢您的帮助
从中更改样式
parent="@android:style/Widget.RatingBar.Small"
Run Code Online (Sandbox Code Playgroud)
至
parent="@*android:style/Widget.RatingBar.Small"
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅以下链接,尤其是从6开始的评论.
http://code.google.com/p/android/issues/detail?id=18659
小智 6
解决方案包括将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>
Run Code Online (Sandbox Code Playgroud)
星星较小,交互仍然有效
当我从 1.6 切换到 2.1 时,我遇到了同样奇怪的问题。删除您风格中的小词并尝试:
android:style/Widget.RatingBar.Small
Run Code Online (Sandbox Code Playgroud)
到
android:style/Widget.RatingBar
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22100 次 |
| 最近记录: |