1.自定义替换提醒☆图片,准备两个图片添加到系统中去:如下:

在drewable下定义一个图片资源ratingbar_drawable.xml
01 |
<? xml version = "1.0" encoding = "utf-8" ?> |
02 |
< layer-list xmlns:android = "http://schemas.android.com/apk/res/android" > |
05 |
android:id = "@+android:id/background" |
06 |
android:drawable = "@drawable/unselect" > |
09 |
android:id = "@+android:id/secondaryProgress" |
10 |
android:drawable = "@drawable/unselect" > |
13 |
android:id = "@+android:id/progress" |
14 |
android:drawable = "@drawable/selected" > |
之后再styles.xml下添加一个标签,这个style继承父style Widget.RatingBar
1 |
< style name = "roomRatingBar" parent = "<a
href=" http://my.oschina.net/asia" target = "_blank" rel = "nofollow" >@android</ a >
:style/Widget.RatingBar"> |
3 |
< item name = "android:progressDrawable" >@drawable/ratingbar_drawable</ item > |
5 |
< item name = "android:minHeight" >48dip</ item > |
7 |
< item name = "android:maxHeight" >48dip</ item > |
之后定义布局文件资源ratingbar.xml;
01 |
<? xml version = "1.0" encoding = "utf-8" ?> |
02 |
< LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
03 |
android:layout_width = "fill_parent" |
04 |
android:layout_height = "fill_parent" |
05 |
android:orientation = "vertical" > |
08 |
android:layout_width = "match_parent" |
09 |
android:layout_height = "wrap_content" |
10 |
style = "@style/roomRatingBar" |
11 |
android:layout_marginLeft = "10dip" |
12 |
android:id = "@+id/ratingbar" |
14 |
android:stepSize = "0.15" |
运行后的效果:

