Custom Rating Bar

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Custom Rating Bar

Postby stelioschar » Tue Aug 24, 2010 8:37 am

Hello to everybody,

I have a problem using a custom rating bar.
The widget that i'm using is the RatingBar. Here is the code.
Code: Select all
<RatingBar
                     android:id="@+id/rate"
                     android:numStars="5"
                     android:stepSize="0.5"
                     android:rating="2.7"
                     android:layout_width="89sp"
                     android:layout_height="16sp"
                     android:layout_alignParentLeft="true"
                     android:layout_alignParentTop="true"
                     android:layout_marginTop="8sp"
                     style="@style/foodRatingBar"
                     android:layout_marginRight="4sp"
                     />


The style that i apply to the RatingBar is called foodRatingBar, with this code:
Code: Select all
   <style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
      <item name="android:progressDrawable">@layout/food_rating_bar_full</item>
      <item name="android:minHeight">48dip</item>
        <item name="android:maxHeight">48dip</item>
   </style>

and the drawable has this structure:
Code: Select all
<?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/food_ratingbar_full_empty" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/food_ratingbar_full_empty" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/food_ratingbar_full_filled" />
</layer-list>


The problem is that if i drag my mouse(in the emulator) up to this rating bar, the value inside the bar changes and it is not permanent and stable.
I would like someone to give me a tip for keeping this rating custom bar unchanged..

Thanks in advance..
stelioschar
Junior Developer
Junior Developer
 
Posts: 18
Joined: Thu Aug 19, 2010 9:18 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 10 guests