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. c++ 字符串拷贝以及合并

    #include<iostream> #include<string> using namespace std; class stringfun { ]; public: vo ...

  2. UVA-11183 Teen Girl Squad (最小树形图、朱刘算法模板)

    题目大意:给一张无向图,求出最小树形图. 题目分析:套朱-刘算法模板就行了... 代码如下: # include<iostream> # include<cstdio> # i ...

  3. Leetcode 63

    //一维dp还是比较难写的class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>&a ...

  4. IOS-适配iOS10以及Xcode8

    现在在苹果的官网上,我们已经可以下载到Xcode8的GM版本了,加上9.14日凌晨,苹果就要正式推出iOS10系统的推送了,在此之际,iOS10的适配已经迫在眉睫啦,不知道Xcode8 beat版本, ...

  5. Powerdesigner颜色设置

    Powerdesigner颜色设置    

  6. 安装wamp后,127.0.0.1可以访问,localhost不能访问

    今天安装wamp后,127.0.0.1可以访问,localhost不能访问,出现 “error You don't have permission to access”的错误, 网上查了下,很多方法都 ...

  7. C++设计模式之中介者模式

    中介者模式:用一个中介对象来封装一系列的对象交互.中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互.中介者模式的例子很多,大到联合国安理会,小到房屋中介,都扮演了 ...

  8. MYeclipes项目导入导出

    导入: 右键,import,

  9. start-stop-daemon自动启动、关闭后台程序参数传递

    /************************************************************************* * start-stop-daemon自动启动.关 ...

  10. .NET/C# 使用反射注册事件

    使用反射,我们可以很容易地在运行时调用一些编译时无法确定的属性.方法等.那么如何注册事件呢? 本文将介绍如何使用反射注册事件. 本文内容 不使用反射 使用反射 安全地使用反射 参考资料 不使用反射 例 ...