Coder Social home page Coder Social logo

simpleratingview's Introduction

SimpleRatingView

一个简单易用的评分组件

特性

  • 不会误点评星
  • 支持设置总分值
  • 支持两种评星的样式:星星和心形
  • 支持设置选中和未选中的颜色
  • 支持设置星星之间的间距
  • 不支持拖动设置评星

示例图

srv

使用方法

  1. 在项目级的build.gradle中添加JitPack仓库:
allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}
  1. 添加依赖:
dependencies {
    ...
    implementation 'com.github.spareyaya:SimpleRatingView:v1.0.5-beta'
}

一个完整属性的使用例子:

<com.github.spareyaya.SimpleRatingView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:starType="star"
        app:numStars="5"
        app:rating="4"
        app:starSize="48dp"
        app:starSpacing="24dp"
        app:primaryColor="#60C720"
        app:secondaryColor="#4EA0F1"
        />

注意:

  1. 以上属性都有默认值,可以自行选择部分属性进行设置
  2. 组件的大小是由padding值、评星数量(numStars)、评星大小(starSize)和评星之间的空隙(starSpacing)决定的:宽度 = 评星大小 * 评星数量 + 评星之间的空隙 * (评星数量 - 1) + paddingLeft + paddingRight,高度 = 评星大小 + paddingTop + paddingBottom,android:layout_widthandroid:layout_height不起作用,建议设置为wrap_content

使用回调事件:

simpleRatingView1.setOnRatingChangeListener(new SimpleRatingView.OnRatingChangeListener() {
    @Override
    public void onRatingChange(int oldRating, int newRating) {
    	Toast.makeText(MainActivity.this, "oldRating:" + oldRating + " newRating:" + newRating, Toast.LENGTH_SHORT).show();
    }
});

simpleratingview's People

Contributors

spareyaya avatar

Watchers

 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.