Hello all i need to perform Ratings in my application... SO i need to create custom Ratings bar... Can Anyone Help me in this?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
For SVG
RatingBar
I used RatingBar custom Vector Drawables superimposing and the answer of erdomester here. This solution traverses all drawables insideSvgRatingBar
view of your layout, so inRecyclerView
it has an overhead.SvgRatingBar.java:
In your layout:
You also have to create rating_bar.xml with two SVG drawables:
You can try this rating bar with much better animations
SmileyRating
Edit
Have a look at custom rating in motorola http://community.developer.motorola.com/t5/Android-App-Development-for/custom-rating-bar-style-using-android-s-ratingBar-small-style/td-p/10462
Updated
styles.xml
This must be located in your values folder
food_rating_bar_full.xml
This file must be in Drawable folder.
food_ratingbar_full_empty.xml
This file must be inside Drawable folder.
food_ratingbar_full_filled.xml
This file must be located in Drawable folder.
main.xml file should look like :
MainActivity.class should look like :
I have used two images:
cookie.jpg
cookiee.jpg
This two images are of same size one is used for identifying selected Rating Bar and other for identifying unselected RatingBar
When creating a custom rating bar that displays a solid gradient line running on a SeekBar-like track, rather than stars, I also encountered a problem related to the vertical centering of the background (track drawable). This is the flawed drawable code I used originally (which generated the problem), as suggested by Android developer and other StackOverflow entries:
The problem here is the first item, which relates to the background of the custom RatingBar. Many entries will tell you to set the layout_minHeight feature to some large value to avoid a vertical spatial disconnect between the thumb and its track. This was not the solution for me - when viewed on a tablet, the background was still drawing to its smaller phone-based size - so the track was consistently positioned well above the center of the RatingBar track. The solution is to remove this entry in the RatingBar drawable, so it now looks like this:
Then, in the style definition of the custom RatingBar, set the layout_background to the the track drawable. Mine looks like this:
(Previously, the background setting here was undefined.).
This is the entry in my layout, which uses both the style and the drawables:
So, to summarize, do not set the background (track) feature in your custom RatingBar drawable, set it in the layout_background feature of your custom RatingBar style. This ensures the track is always vertically centered in a horizontal RatingBar. (Remember, in this custom RatingBar, instead of using stars or other isolated images as the rating, I'm using a gradient line that "grows" or "shrinks" horizontally to display the rating - this rating line uses a SeekBar-like thumb running on a SeekBar-like "track".)
Making the custom rating bar with layer list and selectors is complex, it is better to override the RatingBar class and create a custom RatingBar. createBackgroundDrawableShape() is the function where you should put your empty state png and createProgressDrawableShape() is the function where you should put your filled state png.
Note: This code will not work with svg for now.
The following code works: