RatingBar

android中一个评分的控件

如何使用

Android Studio下:

    dependencies {
compile 'com.hedgehog.ratingbar:app:1.0.2'
}

1,在XML中

<com.hedgehog.ratingbar.RatingBar
android:layout_marginTop="50dp"
android:layout_gravity="center"
android:id="@+id/ratingbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
hedgehog:starCount="5"
hedgehog:clickable="true"
hedgehog:starEmpty="@mipmap/ic_star_empty"
hedgehog:starFill="@mipmap/ic_star_fill"
hedgehog:starImageSize="30dp"
/>

注意:别忘了命名空间

    xmlns:hedgehog="http://schemas.android.com/apk/res-auto"

2,在java代码中

   RatingBar mRatingBar = (RatingBar) findViewById(R.id.ratingbar);
mRatingBar.setOnRatingChangeListener(
new RatingBar.OnRatingChangeListener() {
@Override
public void onRatingChange(int RatingCount) {
Toast.makeText(MainActivity.this,"the fill star is"+RatingCount,Toast.LENGTH_LONG).show();
}
}
);
mRatingBar.setStar(5);
mRatingBar.setmClickable(true);
mRatingBar.setStarImageSize(16f);
mRatingBar.setStarEmptyDrawable(getResources().getDrawable(R.mipmap.ic_star_empty));
mRatingBar.setStarFillDrawable(getResources().getDrawable(R.mipmap.ic_star_fill));

关于

因为项目中需要,但是android本身对这个控件的支持并不是很好
所以打算用一个开源的,可是并没有找到称心如意的
然后发现了这个 * [Android_custom_ratingbarview](https://github.com/JackWong025/Android_custom_ratingbarview) 在他的基础上做了些许修改后发布
而且让使用Android Studio的同学更加容易引入,不用在这个小东西上浪费时间
同时我也学习了如何用Android Studio发布开源项目到Jcenter

最后

感谢JackWong的开源项目

项目地址:https://github.com/hedge-hog/RatingBar

android中一个评分的控件的更多相关文章

  1. Android中的自定义视图控件

    简介 当现有控件不能满足需求时,就需要自定义控件. 自定义控件属性 自定义控件首先要继承自View,重写两个构造函数. 第一个是代码中使用的: public MyRect(Context contex ...

  2. Android中使用shape来定义控件

    本文章转接于:http://kofi1122.blog.51cto.com/2815761/521605 Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对s ...

  3. android中的五大布局(控件的容器,可以放button等控件)

    一.android中五大布局相当于是容器,这些容器里可以放控件也可以放另一个容器,子控件和布局都需要制定属性. 1.相对布局:RelativeLayout @1控件默认堆叠排列,需要制定控件的相对位置 ...

  4. android 中通过代码创建控件

    package bvb.de.openadbwireless.circle; import android.annotation.TargetApi; import android.app.Activ ...

  5. android中动态修改ImageView控件的宽高度

    本例实现了动态修改ImageView控件的宽高度,有两个按钮,一个按钮实现放大image,一个按钮实现缩小image activity_main.xml <?xml version=" ...

  6. android中关于时间的控件

    1.日期选择器 <DatePicker android:layout_width="wrap_content" android:layout_height="wra ...

  7. Android 拖动条/滑动条控件、星级评分控件

    ProgressBar有2个子控件: SeekBar   拖动条控件 RatingBar   星级评分控件 1.拖动条控件 <SeekBar android:layout_width=" ...

  8. Android中查找一个Layout中指定的子控件

    我们通常希望查找一个页面中指定类型的控件,单个控件知道id很容易找到,但是如果是多个呢?或者说是在程序中自定义的控件,且不知道id怎么办呢?如想找到页面中的Spinner,可用以下方法 /** * 从 ...

  9. 一个神奇的控件——Android CoordinatorLayout与Behavior使用指南

    CoordinatorLayout是support.design包中的控件,它可以说是Design库中最重要的控件. 本文通过模仿知乎介绍了自定义Behavior,通过模仿百度地图介绍了BottomS ...

随机推荐

  1. vue-cli 3 is not a modual err

    <srcipt> </srcipt> don't empty normal write <srcipt> export default {}; </scrip ...

  2. mongo学亮的分享

    # MongoDB 集群部署## 关键词* 集群* 副本集* 分片## MongoDB集群部署>今天主要来说说Mongodb的三种集群方式的搭建Replica Set副本集 / Sharding ...

  3. Python str 与 bytes 类型 之间的转换

    bytes:字节数组,通常用它可以描述 “一个字符串”,只不过该字符串是  “bytes类型”,所以容易与str类型混淆,他们二者之间的转换: https://blog.csdn.net/lanchu ...

  4. .Net Core中使用UEditor

    一.下载解压UEditor的.net版本(这个直接使用的话是asp.net的版本) 我下载的是这个 再给留上地址http://ueditor.baidu.com/website/download.ht ...

  5. 各种排序算法思想复杂度及其java程序实现

    一.冒泡排序(BubbleSort)1. 基本思想: 设排序表长为n,从后向前或者从前向后两两比较相邻元素的值,如果两者的相对次序不对(A[i-1] > A[i]),则交换它们, 其结果是将最小 ...

  6. 玲珑杯 round18 A 计算几何瞎暴力

    题目链接 : http://www.ifrog.cc/acm/problem/1143 当时没看到坐标的数据范围= =看到讨论才意识到,不同的坐标最多只有1k多个,完全可以暴力做法,不过也要一些技巧. ...

  7. 表统计信息(storge)相关

    select t1.NUM_ROWS,t1.BLOCKS,t1.EMPTY_BLOCKS,t1.AVG_SPACE,t1.CHAIN_CNT,t1.AVG_ROW_LEN from user_tab_ ...

  8. 解决IE6中img标签 图片透明

    <!--[if IE 6]> <script type="text/javascript"> function correctPNG() { for (va ...

  9. 关闭定时器(setTimeout/clearTimeout|setInterval/clearInterval)

    1.1 开启Timeout程序: scope.setTimeout("functionName()" | functionHandle, timeValue) 返回值:timerI ...

  10. web 常用富文本编辑器

    1. 百度家的 UEditor  官网地址http://ueditor.baidu.com/website/;在线演示地址:http://ueditor.baidu.com/website/onlin ...