SimpleRatingBar


Source link: https://github.com/ome450901/SimpleRatingBar

SimpleRatingBar

This is a very simple RatingBar library, which you can just simply extend BaseRatingBar to implement your own animation RatingBar in a few steps!

Current we already have three RatingBars :

  • BaseRatingBar
    A RatingBar without any animation.
  • ScaleRatingBar
    A RatingBar with progressive and scale animation.
  • RotationRatingBar (contributed by nappannda)
    A RatingBar with progressive and rotate animation.

Demo



Icon made by Freepik from www.flaticon.com

What's New (v1.3.2)

  • Fix fillRatingBar method bug when RatingBar use in RecyclerView.
  • Allow half star through click event. (contributed by ANPez)
  • Load drawables from XML using ContextCompat to allow vectordrawables. (contributed by ANPez)
  • Implement new EntryActivity in demo project

Feature

  • Support step size setting(range from 0.1 to 1.0).
  • Support float rating
     Now you can set a float rating like 3.5, 2.3, 4.7, etc., but you only need to provide two images: filled and empty, and Library will auto processes your images to support float showing!
  • Add touchable setting
  • Add ClearRatingEnabled setting
  • Stars width and height setting. (contributed by zhangruize)
  • Support use touch to change rating
  • Custom drawable's padding
  • Custom your empty and filled drawable
  • Click again to clear rating
  • Rotate animation
  • Scale animation

How To Use

Install

from JitPack:

allprojects {

  repositories {

...

maven {
 url 'https://jitpack.io' 
}

  
}
 
}
  dependencies {

  compile 'com.github.ome450901:SimpleRatingBar:1.3.2' 
}

In Xml

<com.willy.ratingbar.ScaleRatingBar

xmlns:rb="http://schemas.android.com/apk/res-auto"

android:id="@+id/simpleRatingBar"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

rb:numStars="3"

rb:rating="2"

rb:starWidth="30dp"

rb:starHeight="30dp"

rb:starPadding="15"

rb:stepSize="0.5"

rb:touchable="true"

rb:clearRatingEnabled="true"

rb:drawableEmpty="@drawable/start_empty"

rb:drawableFilled="@drawable/star_filled"> </com.willy.ratingbar.ScaleRatingBar>

In Your Code

ScaleRatingBar ratingBar = new ScaleRatingBar(this);
 ratingBar.setNumStars(5);
 ratingBar.setRating(3);
 ratingBar.setStarPadding(10);
 ratingBar.setStepSize(0.5f);
 ratingbar.setTouchable(true);
 ratingbar.setClearRatingEnabled(true);
 ratingBar.setEmptyDrawableRes(R.drawable.start_empty);
 ratingBar.setFilledDrawableRes(R.drawable.start_empty);
 ratingBar.setOnRatingChangeListener(new BaseRatingBar.OnRatingChangeListener() {

  @Override

public void onRatingChange(BaseRatingBar ratingBar, int rating) {

 Log.e(TAG, "onRatingChange: " + rating);

  
}
 
}
);

Want to Implement Your Own Animation?

Only 2 Steps you need to do:

  • Create a class that extend BaseRatingBar
  • Override the emptyRatingBar and fillRatingBar this two method, and then you can start implement your own animaion!

You can follow ScaleRatingBar to implement your own class.

Todo

  • Implement some other animations
  • Find a better way to implement animation

About Me

Follow me at Medium.

License

MIT License  Copyright (c) 2017 WillyYu  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

Resources

Easily add four tabbed bottom navigation bar in your app.

This library aids in adding four tabs in Bottom Navigation Bar, as easily and fast as possible. Th result looks like as it is commonly found in most of the apps, like Quora and others.

Point to note: This library is significantly different from what Google has provided for Android Developers. The official Bottom Navigation Bar from Google doesn't show text when it has 4 tabs. But this library shows icon and text with four bottom bars.

A simple library for Android to get images from gallery or from camera.

Application for saving photos/videos from Instagram.

Last images added or downloaded to the device. Like the functionality of Facebook, Instagram and Whatsapp.

RxJava2 and Kotlin for Firebase.

Android Horizontal Stack View.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes