Git Product home page Git Product logo

ratingview's Introduction

RatingView

用来显示评分、评价的自定义视图控件。灵感来源于360手机安全卫士。此控件已经应用在我个人开发的户外探子,有兴趣的可以看看。

This custom view is using for rating, scoring, marking. Inspired by 360 mobile security guards.

预览图 Screenshots

demo1 demo2 demo3 demoapp

集成 Integrate

  • 添加一个dependency到你的build.gradle // Add a dependency to your build.gradle:
dependencies {
    compile 'com.deanguo.ratingview:library:1.3.0'
}
  • 或者将library导入到工程中 // Or import library as a model to your project

  • 或者将library中的RatingBarRatingView,和attrs.xml复制到你的项目中去 // Or copy RatingBar,RatingView,attrs.xml from library to your project

使用 Usage

####初始化 Initialization 添加com.deanguo.ratingview.RatingView 到你的布局文件中
Add com.deanguo.ratingview.RatingView to your layout XML file.

<com.deanguo.ratingview.RatingView
        android:id="@+id/rating_view"
        android:layout_width="200dp"
        android:layout_height="200dp">
    </com.deanguo.ratingview.RatingView>

之后在代码中调用
Then using in java code

RatingView view = (RatingView) this.findViewById(R.id.rating_view);
        view.addRatingBar(new RatingBar(8, "HARD"));
        view.addRatingBar(new RatingBar(8, "VIEW"));
        view.addRatingBar(new RatingBar(8, "WEATHER"));
        view.addRatingBar(new RatingBar(8, "TRAFFIC"));
        view.show();

####设置颜色 Setting Color #####RatingView

<com.deanguo.ratingview.RatingView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/rating_view"
        android:layout_width="200dp"
        android:layout_height="200dp"
        app:rating_default_color="@color/white" />
    RatingView view = (RatingView) this.findViewById(R.id.rating_view);
    view.setDefaultColor(getColor(R.color.white));

#####RatingBar

RatingBar hard = new RatingBar(8, "HARD");
hard.setRatingBarColor(getColor(R.color.white));

也可以使用下面方法深度定义Ratingbar样式
Using below method to create your own Ratingbar.
setRatedColor(int color)
setUnRatedColor(int color)
setTitleColor(int color)
setOutlineColor(int color)
setShadowColor(int color)
setRate(int rate)
setMaxRate(int maxRate)
####自定义视图 Custom View 可以再RatingView中间放置任意视图,比如文字,图片,按钮,布局,控件等
You can add any view,layout in RatingView

<com.deanguo.ratingview.RatingView
        android:id="@+id/rating_view"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerInParent="true">
        <RelativeLayout
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center"
            >
            <TextView
                android:visibility="invisible"
                android:id="@+id/center_btn"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerInParent="true"
                android:text="update"
                android:gravity="center"
                android:textColor="#ffffff"
                android:textSize="20dp" />

        </RelativeLayout>
    </com.deanguo.ratingview.RatingView>

####动画监听 Animation Listener

RatingView view = (RatingView) this.findViewById(R.id.rating_view);
        view.setAnimatorListener(new RatingView.AnimatorListener() {
            @Override
            public void onRotateStart() {
            }

            @Override
            public void onRotateEnd() {
            }

            @Override
            public void onRatingStart() {
            }

            @Override
            public void onRatingEnd() {
            }
        });

更多使用方法请参考项目中的sample
please reference the sample code for more information.

License

Copyright 2016 Dean Guo

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.

ratingview's People

Contributors

a396901990 avatar

Watchers

James Cloos 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.