android自定义笑脸,GitHub
ThreeRatingBar
自定义笑脸评分条
效果图
attrs.xml
//间距
//默认图标
//差评图标
//好评图标
//半星差图标
//半星好图标
//星星大小
//星星数量
//当前评级
xml引用
android:id="@+id/ratingTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
app:default_icon="@mipmap/evaluate_default_face"
app:rating="1.36"
android:layout_toRightOf="@+id/tv_1"
app:selection_icon_bad="@drawable/rating_bar_bad_smile"
app:selection_icon_good="@drawable/rating_bar"
app:selection_icon_half_good="@mipmap/evaluate_yellow_half"
app:selection_icon_half_bad="@mipmap/evaluate_bad_face_half"
app:starCount="5"
app:starImageSize="96"/>
使用
@Bind(id.rate_communicate)
ThreeLevelRatingBarView rateCommunicate;
//禁止再点击
rateCommunicate.setClickable(false);
//获取并设置rating
CommunicationScore = rateCommunicate.getRating() + "";
rateCommunicate.setRating(Float.parseFloat(CommunicationScore));
//点击监听
rateCommunicate.setOnRatingBarChangeListener(new ThreeLevelRatingBarView.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(float RatingScore) {
if (RatingScore > 2) {
tvCommunicate.setText("好");
} else if (RatingScore <= 1) {
tvCommunicate.setText("差");
} else {
tvCommunicate.setText("一般");
}
}
});