Git Product home page Git Product logo

simpleratingbar's Introduction

SimpleRatingBar

JitPack

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.4.1)

  • Fix minimum stars not working in recyclerView bug
  • Implement minimum stars property
  • Add setStarWidth and setStarHeight API (unit is pixel)

Feature

  • Allow half star through click event. (contributed by ANPez)
  • 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!
  • 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
  • IsIndicator, Scrollable, Touchable and Clickable settings
  • Rotate animation
  • Scale animation

How To Use

Install

from JitPack:

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

dependencies {
    compile 'com.github.ome450901:SimpleRatingBar:1.4.1'
}

In Xml

<com.willy.ratingbar.ScaleRatingBar
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/simpleRatingBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srb_numStars="3"
        app:srb_minimumStars="1"
        app:srb_rating="2"
        app:srb_starWidth="30dp"
        app:srb_starHeight="30dp"
        app:srb_starPadding="15dp"
        app:srb_stepSize="0.5"
        app:srb_isIndicator="false"
        app:srb_clickable="true"
        app:srb_scrollable="true"
        app:srb_clearRatingEnabled="true"
        app:srb_drawableEmpty="@drawable/start_empty"
        app:srb_drawableFilled="@drawable/star_filled">
</com.willy.ratingbar.ScaleRatingBar>

In Your Code

ScaleRatingBar ratingBar = new ScaleRatingBar(this);
ratingBar.setNumStars(5);
ratingBar.setMinimumStars(1);
ratingBar.setRating(3);
ratingBar.setStarPadding(10);
ratingBar.setStepSize(0.5f);
ratingBar.setWidth(105);
ratingBar.setHeight(105);
ratingbar.setIsIndicator(false);
ratingbar.setClickable(true);
ratingbar.setScrollable(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 TWO 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) 2018 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.

simpleratingbar's People

Contributors

williamyyu avatar nappannda avatar anpez avatar harshsharma94 avatar desmese avatar zhangruize avatar

Stargazers

Sunshine avatar

Watchers

James Cloos avatar Sunshine avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.