本文主要是介绍设置RatingBar的图片,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1. 资源
android_ratingbar_single_light.png
android_ratingbar_single.png
2. 设置状态
yellow_star_rating_bar_full.xml
<? xml version = "1.0" encoding = "utf-8" ?>
< layer-list
xmlns:android = "http://schemas.android.com/apk/res/android" >
< item android:id = "@android:id/background" android:drawable = "@drawable/android_ratingbar_single" />
< item android:id = "@android:id/progress" android:drawable = "@drawable/android_ratingbar_single_light" />
</ layer-list >
3. 定义style
< style name = "yellowStarRatingBar" parent = "@android:style/Widget.RatingBar" >
< item name = "android:maxHeight" > 20.0dip </ item >
< item name = "android:progressDrawable" > @drawable/yellow_star_rating_bar_full </ item >
< item name = "android:minHeight" > 20.0dip </ item >
</ style >
< RatingBar android:id = "@id/comment_grade_star" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_marginLeft = "5.0dip" android:layout_marginTop = "10.0dip" android:rating = "5.0" android:layout_toRightOf = "@id/comment_grade" android:layout_below = "@id/comment_title_name_content" style = "@style/yellowStarRatingBar" />
5. 效果图
这篇关于设置RatingBar的图片的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!