GithubHelp home page GithubHelp logo

ratingbar's Introduction

RatingBar

##中文版 ##a custom Ratingbar in android image

How to use

###Android Studio:

    dependencies {
        compile 'com.hedgehog.ratingbar:app:1.1.2'
    }

###1,In xml

<com.hedgehog.ratingbar.RatingBar
    android:id="@+id/ratingbar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    hedgehog:clickable="true"
    hedgehog:halfstart="true"
    hedgehog:starCount="5"
    hedgehog:starEmpty="@mipmap/star_empty"
    hedgehog:starFill="@mipmap/star_full"
    hedgehog:starHalf="@mipmap/star_half"
    hedgehog:starImageHeight="90dp"
    hedgehog:starImageWidth="70dp"
    hedgehog:starImagePadding="20dp"/>

###method statement

method action
hedgehog:clickable="true" Could you click
hedgehog:halfstart="true" Whether to support half a star
hedgehog:starCount="N" The total number of stars (int)
hedgehog:starEmpty="@mipmap/star_empty" empty star
hedgehog:starFill="@mipmap/star_full" full star
hedgehog:starHalf="@mipmap/star_half" half star
hedgehog:starImageHeight="90dp" the height of the stars
hedgehog:starImageWidth="70dp" the width of the star
hedgehog:starImagePadding="20dp" the padding of the star
###Don't forget to namespace
xmlns:hedgehog="http://schemas.android.com/apk/res-auto"

###2,In Java code

```
   RatingBar mRatingBar = (RatingBar) findViewById(R.id.ratingbar);
    mRatingBar.setStarEmptyDrawable(getResources().getDrawable(R.mipmap.star_empty));
    mRatingBar.setStarHalfDrawable(getResources().getDrawable(R.mipmap.star_half));
    mRatingBar.setStarFillDrawable(getResources().getDrawable(R.mipmap.star_full));
    mRatingBar.setStarCount(5);
    mRatingBar.setStar(2.5f);
    mRatingBar.halfStar(true);
    mRatingBar.setmClickable(true);
    mRatingBar.setStarImageWidth(120f);
    mRatingBar.setStarImageHeight(60f);
    mRatingBar.setImagePadding(35);
    mRatingBar.setOnRatingChangeListener(
            new RatingBar.OnRatingChangeListener() {
                @Override
                public void onRatingChange(float RatingCount) {
                    Toast.makeText(MainActivity.this, "the fill star is" + RatingCount, Toast.LENGTH_SHORT).show();
                }
            }
    );

    ```

###method statement

method action
mRatingBar.setStarCount(5); The total number of stars
mRatingBar.setStar(2.5f); Fill the total number of the stars
mRatingBar.halfStar(true); Whether set up half a star
mRatingBar.setmClickable(true); Whether the Settings can be click
mRatingBar.setStarImageWidth(120f); the width of the stars
mRatingBar.setStarImageHeight(60f); the height of the stars
mRatingBar.setImagePadding(35); the padding of the stars

#about Because the project need this function, but the android itself on the propagation of the Ratingbar support is very bad, so intend to write their own a, because my ability is limited, a lot of the function is not perfect, if you have a better solution, welcome to tell me, thank you

#unsolved

  • You can set the padding between the stars,But because the Ratingbar is rewriting Imageview, so distance setting still need to fine tune
  • You can set up half a star,but this method is very bad,Using this method is not recommended,Look at the code if you want to know the details,Please let me know if you have a good solution

#Thank Thanks the Android_custom_ratingbarview You can look at it
Thankslingguohuifor his code

#License

Copyright 2015 hedge_hog

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

ratingbar's People

Contributors

chanhohn avatar

Watchers

 avatar  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.