Android about Ratingbar Rating strips

Source: Internet
Author: User

Ratingbar Scoring bar System UI controls

Write Main.xml file :

<ratingbar
Android:id= "@+id/ratingbar"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_marginleft= "10dip"
Android:isindicator= "true"
Android:numstars= "5"
android:rating= "5" >
</RatingBar>


Effect slag slag: 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/37/wKioL1SVMkeCQr88AABhY9wBWa8748.jpg "title=" Ratingbar.jpg "alt=" Wkiol1svmkecqr88aabhy9wbwa8748.jpg "/>


android:numstars= "5" setting shows the number of stars is 5, android:rating= "5" Setting the number selected is 5.

Android:isindicator= "true" setting does not change its state when selected


Custom Ratingbar Scoring bar


Above Ratingbar add a style property, remove android:isindicator= "true" property

1.main.xml Write down:


<ratingbar
Android:id= "@+id/ratingbar"
style= "@style/myratingbar"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_marginleft= "10dip"
Android:numstars= "5"
android:rating= "5" >
</RatingBar>


myratingbar. xml written in 2.values directory:


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

<resources>

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

<itemname= "Android:progressdrawable" > @drawable/select_rating_bar</item>

<itemname= "Android:minheight" >16dip</item>

<itemname= "Android:maxheight" >16dip</item>

</style>

</resources>


Parent= "@android: Style/widget.ratingbar" inherits the style of the system Ratingbar

<itemname= "Android:minheight" >16dip</item> <itemname= "Android:maxheight" >16dip</item> Control the maximum and minimum height of the component


3.drawable directory under/select_rating_bar.xml writing:


<?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/luck" >
</item>
<item
Android:id= "@+android:id/secondaryprogress"
android:drawable= "@drawable/secondxing" >
</item>
<item
Android:id= "@+android:id/progress"
android:drawable= "@drawable/xing" >
</item>

</layer-list>


This sets the first level progress background picture (selected picture) two level progress background picture (unselected picture) and background picture, the application runtime will redraw these components


Recommendation: A more comprehensive example: http://www.apkbus.com/android-51346-1-1.html

Android about Ratingbar Rating strips

Related Article

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.