CaiJingLong/Android-CustomRatingBar


a custom rating bar

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.CaiJingLong:Android-CustomRatingBar:'
	}
	dependencies {
		implementation("com.github.CaiJingLong:Android-CustomRatingBar:")
	}
	<dependency>
	    <groupId>com.github.CaiJingLong</groupId>
	    <artifactId>Android-CustomRatingBar</artifactId>
	    <version></version>
	</dependency>

                            
    libraryDependencies += "com.github.CaiJingLong" % "Android-CustomRatingBar" % ""
        
        

                            
    :dependencies [[com.github.CaiJingLong/Android-CustomRatingBar ""]]
        
        

Readme


#Android-CustomRatingBar Custom Rating Bar

Release

doc

English doc

中文文档

project

  • platform :Android
  • language :java
  • version :1.0

install

Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
        compile 'com.github.CaiJingLong:Android-CustomRatingBar:-SNAPSHOT'
}

screenshot


layout

description


extends viewgroup

xml attribute

        <declare-styleable name="RB">
        <!--star width-->
        <attr name="starWidth" format="dimension"/>
        <!--star height-->
        <attr name="starHeight" format="dimension"/>
        <!--star number-->
        <attr name="maxStar" format="integer"/>
        <!--min selected star-->
        <attr name="minStar" format="float"/>
        <!--current star count -->
        <attr name="currentStar" format="float"/>
        <!--star padding-->
        <attr name="padding" format="dimension"/>
        <!--empty star src-->
        <attr name="emptyStar" format="reference"/>
        <!--full star src-->
        <attr name="fullStar" format="reference"/>
        <!--half star src-->
        <attr name="halfStar" format="reference"/>
        <!--is can be change-->
        <attr name="canChange" format="boolean"/>
    </declare-styleable>

use


xml文件



    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="10dp"
        tools:context="com.dn.ratingbar.MainActivity">

        <com.kikt.view.CustomRatingBar
            android:id="@+id/rb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            app:currentStar="3.5"
            app:fullStar="@mipmap/ic_launcher"
            app:maxStar="5"
            app:minStar="0.5"
            app:padding="3dp"
            app:starHeight="30dp"
            app:starWidth="30dp"/>

        <com.kikt.view.CustomRatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            app:currentStar="3.5"
            app:maxStar="5"
            app:minStar="0.5"
            app:padding="3dp"
            app:starHeight="30dp"
            app:starWidth="30dp"/>

        <com.kikt.view.CustomRatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            app:currentStar="4"
            app:maxStar="6"
            app:minStar="1.5"
            app:padding="3dp"
            app:starHeight="50dp"
            app:starWidth="50dp"/>
    </LinearLayout>

use java code



    void onCreate(){
        mRb = findViewById(R.id.rb);
        mRb.setOnStarChangeListener(this);

        @Override
        public void onStarChange(CustomRatingBar ratingBar, float star) {
            Log.d("MainActivity", "star:" + star);
        }
    }

about me