Ratingbar is a scoring bar control, with the default effect being several green stars, and customizing its style if you want to change it to a different custom picture. The first is the layout file:
1 <RatingbarAndroid:id= "@+id/app_ratingbar"style= "@style/myratingbar" 2 Android:layout_margintop= "4dip"Android:layout_width= "Wrap_content" 3 Android:layout_height= "Wrap_content"Android:numstars= "5" 4 Android:isindicator= "true"android:rating= "5" />
Where the android:numstars= "5" setting shows the number of stars is 5, android:rating= "5" Set the selected number is 5, that is, all selected
Android:isindicator= "True" sets the score bar to show only the results cannot be changed by clicking on the selected state.
Then build the Styles.xml file code in the Res/values directory:
1 <?XML version= "1.0" encoding= "Utf-8"?> 2 <Resources> 3 <stylename= "Myratingbar"Parent= "@android: Style/widget.ratingbar"> 4 <Itemname= "Android:progressdrawable">@drawable/food_rating_bar_full</Item> 5 <Itemname= "Android:minheight">15dip</Item> 6 <Itemname= "Android:maxheight">15dip</Item> 7 </style> 8 </Resources>
Android:progressdrawable is the scoring bar pattern. Next, build the Food_rating_bar_full.xml file in the Res/drawable directory
Code:
1 <?XML version= "1.0" encoding= "Utf-8"?> 2 <layer-listxmlns:android= "Http://schemas.android.com/apk/res/android"> 3 <ItemAndroid:id= "@+android:id/background" 4 android:drawable= "@drawable/rating" /> 5 <ItemAndroid:id= "@+android:id/secondaryprogress" 6 android:drawable= "@drawable/rating" /> 7 <ItemAndroid:id= "@+android:id/progress" 8 android:drawable= "@drawable/rating_show" /> 9 </layer-list>
<item android:id= "@+android:id/progress" android:drawable= "@drawable/rating_show"/> To set the scoring pattern to Rating_ Show.png, that is, the pattern when selected;
<item android:id= "@+android:id/background" android:drawable= "@drawable/rating"/> To set the background pattern for Rating.png, which is the pattern when selected.
Android Scoring bar Ratingbar custom settings