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 ?
Asked
Active
Viewed 560 times
1 Answers
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
-
1I will check it out and give right answer if it comes out helpfull thanks man :) – Karim Bibars Jul 03 '14 at 14:11
-
No problem. I regularly use selectors. They are simple and easy on the resources. – Trent Pierce Jul 03 '14 at 14:13
-
ok now I get what you meant but what I wanted to do is a bar like youtube where it fills a portion of a specific view everytime the number of likes increases or so .. not just change color – Karim Bibars Jul 03 '14 at 14:18
-
well you have put me on the right track i guess , its a matter of me working hard from now on thanks – Karim Bibars Jul 03 '14 at 14:43