1

Now I have this task where I should create a rating bar just like youtube in my app , and so my idea was to have a textview where I set its background to a color but then remove the color according to an equation I will make so it displays only a percentage of it... any idea how can I do this or where to look ?

Karim Bibars
  • 75
  • 1
  • 9

1 Answers1

0

The simplest way to do this would be to create a selector.xml. You would assign android:background="@drawable/selector". Your selector would decide which background color to show based on what percentage you have assigned.

This link explains how to use selectors with buttons. It should help to get you on the right track...http://developer.android.com/guide/topics/resources/color-list-resource.html

EDIT: You can still accomplish a custom progress bar by xml. It is very similar to the selector. Just think of it as many more selectors based on progress instead of state. Here is a nice example...Custom Drawable for ProgressBar/ProgressDialog

You can also look into xml animations. They are similar.

Community
  • 1
  • 1
Trent Pierce
  • 387
  • 3
  • 22