RatingView
用来显示评分、评价的自定义视图控件。灵感来源于360手机安全卫士。此控件已经应用在我个人开发的户外探子,有兴趣的可以看看。
This custom view is using for rating, scoring, marking. Inspired by 360 mobile security guards.
预览图 Screenshots
集成 Integrate
- 添加一个dependency到你的
build.gradle
// Add a dependency to yourbuild.gradle
:
dependencies {
compile 'com.deanguo.ratingview:library:1.3.0'
}
- 或者将library导入到工程中 // Or import library as a model to your project
- 或者将library中的
RatingBar
,RatingView
,和attrs.xml
复制到你的项目中去 // Or copyRatingBar
,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() {
}
});
更多使用方法请参考项目中的samplepleaseance the sample code for more information.
附件下载地址:https://github.com/a396901990/RatingView