Android ApiDemos example resolution (187): Views-& gt; Rating Bar

Source: Internet
Author: User

This example introduces the usage of RatingBar. RatingBar is a subclass of SeekBar and ProgressBar. It uses pentagram to show the same score. By default, RatingBar users can change the score value by using the direction keys or touch/drag. ratingBarStyleSmall and ratingBarStyleLarge of the other two styles generally do not support user interaction and are used to display the score result.

SetNumStarts can set the number of five-pointed stars in the comment column. Let's take a look at the XML definition in this example:

<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: paddingLeft = "10dip"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">

<RatingBar android: id = "@ + id/ratingbar1 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: numStars = "3 ″
Android: rating = "2.5"/>

<RatingBar android: id = "@ + id/ratingbar2 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: numStars = "5 ″
Android: rating = "2.25"/>

<LinearLayout
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: layout_marginTop = "10dip">

<TextView android: id = "@ + id/rating"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"/>

<RatingBar android: id = "@ + id/small_ratingbar"
Style = "? Android: attr/ratingBarStyleSmall"
Android: layout_marginLeft = "5dip"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "center_vertical"/>

</LinearLayout>

<RatingBar android: id = "@ + id/indicator_ratingbar"
Style = "? Android: attr/ratingBarStyleIndicator"
Android: layout_marginLeft = "5dip"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "center_vertical"/>

</LinearLayout>

RatingBar provides an event response score change.

OnRatingChanged (RatingBar ratingBar, float rating, boolean fromTouch)

 

 

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.