1.在build.gradle中添加依赖
compile 'com.azhon:ratingbar:1.3.0'
2.布局使用
<com.azhong.rattingbar.RatingBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
a_zhon:clickable="true"
a_zhon:image_height="36dp"
a_zhon:image_padding="3dp"
a_zhon:image_width="36dp"
a_zhon:star="1"
a_zhon:star_count="5"
a_zhon:star_img="@mipmap/star"
a_zhon:unstar_img="@mipmap/unstar" />
3.布局属性介绍
<!--填充图片-->
<attr name="star_img" format="reference" />
<!--默认图片-->
<attr name="unstar_img" format="reference" />
<!--图片宽度-->
<attr name="image_width" format="dimension" />
<!--图片高度-->
<attr name="image_height" format="dimension" />
<!--图片之间的间距-->
<attr name="image_padding" format="dimension" />
<!--图片总数-->
<attr name="star_count" format="integer" />
<!--填充的图片数量-->
<attr name="star" format="integer" />
<!--是否可以点击-->
<attr name="clickable" format="boolean" />
- 添加星级改变监听
ratingBar.setOnStarChangeListener()
Copyright [2017-11-22] [阿钟]
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.