Android Tutorial case: Android Replacement Ratingbar Pictures

Source: Internet
Author: User

The Wheat Academy's Android teacher gave you a picture of us speaking Android more unratingbar when it comes to Ratingbar is a good component of our system showing fractions, but we generally want to make the ratingbar more beautiful to decorate, To replace the system's default image with a picture that looks better, the system defaults to this:

Xml Code   

1. <?xml version= "1.0" encoding= "Utf-8"?>

2. <resources>

3. <style name= "Foodratingbar" parent= "@android: Style/widget.ratingbar">

4. <item name= "android:progressdrawable">@drawable/food_ratingbar_full</item>< /c6>

5. <item name= "Android:minheight">48dip</item>

6. <item name= "Android:maxheight">48dip</item>

7. </style>

8. </resources>


Then build the Food_rating_bar_full.xml file under the Drawable folder, with the following contents:

Xml Code   

1. <?xml version= "1.0" encoding= "Utf-8"?>

2. <layer-list xmlns:android= "http://schemas.android.com/apk/res/android">

3. <item android:id= "@+android:id/background"

4. android:drawable= "@drawable/food_ratingbar_full_empty" />

5. <item android:id= "@+android:id/secondaryprogress"

6. android:drawable= "@drawable/food_ratingbar_full_empty" />

7. <item android:id= "@+android:id/progress"

8. android:drawable= "@drawable/food_ratingbar_full_filled" />

9. </layer-list>


Food_ratingbar_full_empty is the image effect that is not selected, food_ratingbar_full_filled the picture effect is selected.
Finally, put the style into the Ratingbar to achieve your picture effect:


Xml Code   

1. <ratingbar android:id= "@+id/my_rating_bar"

2 .....

3. style= "@style/foodratingbar" />

Android Tutorial case: Android Replacement Ratingbar Pictures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.