android中一个评分的控件
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中一个评分的控件的更多相关文章
- Android中的自定义视图控件
简介 当现有控件不能满足需求时,就需要自定义控件. 自定义控件属性 自定义控件首先要继承自View,重写两个构造函数. 第一个是代码中使用的: public MyRect(Context contex ...
- Android中使用shape来定义控件
本文章转接于:http://kofi1122.blog.51cto.com/2815761/521605 Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对s ...
- android中的五大布局(控件的容器,可以放button等控件)
一.android中五大布局相当于是容器,这些容器里可以放控件也可以放另一个容器,子控件和布局都需要制定属性. 1.相对布局:RelativeLayout @1控件默认堆叠排列,需要制定控件的相对位置 ...
- android 中通过代码创建控件
package bvb.de.openadbwireless.circle; import android.annotation.TargetApi; import android.app.Activ ...
- android中动态修改ImageView控件的宽高度
本例实现了动态修改ImageView控件的宽高度,有两个按钮,一个按钮实现放大image,一个按钮实现缩小image activity_main.xml <?xml version=" ...
- android中关于时间的控件
1.日期选择器 <DatePicker android:layout_width="wrap_content" android:layout_height="wra ...
- Android 拖动条/滑动条控件、星级评分控件
ProgressBar有2个子控件: SeekBar 拖动条控件 RatingBar 星级评分控件 1.拖动条控件 <SeekBar android:layout_width=" ...
- Android中查找一个Layout中指定的子控件
我们通常希望查找一个页面中指定类型的控件,单个控件知道id很容易找到,但是如果是多个呢?或者说是在程序中自定义的控件,且不知道id怎么办呢?如想找到页面中的Spinner,可用以下方法 /** * 从 ...
- 一个神奇的控件——Android CoordinatorLayout与Behavior使用指南
CoordinatorLayout是support.design包中的控件,它可以说是Design库中最重要的控件. 本文通过模仿知乎介绍了自定义Behavior,通过模仿百度地图介绍了BottomS ...
随机推荐
- BZOJ 3572 【HNOI2014】 世界树
题目链接:世界树 首先看到\(\sum m_i\le 3\times 10^5\)这个条件,显然这道题就需要用虚树了. 在我们构建出虚树之后,就可以用两遍\(dfs\)来求出离每个点最近的议事处了.然 ...
- Spring IOC容器的初始化流程
IOC初始化流程 Resource定位:指对BeanDefinition的资源定位过程.Bean 可能定义在XML中,或者是一个注解,或者是其他形式.这些都被用Resource来定位, 读取Resou ...
- SSH基本管理和配置文件的使用
服务端:linl_S IP:10.0.0.15 客户端:lin_C IP:10.0.0.16 SSHD服务 SSH协议:安全外壳协议.为Secure Shell的缩写.SSH为建立在应 ...
- K-Means & Sequential Leader Clustering
2017-12-31 19:08:37 k-平均算法源于信号处理中的一种向量量化方法,现在则更多地作为一种聚类分析方法流行于数据挖掘领域.k-means的目的是:把样本划分到k个聚类中,使得每个点都属 ...
- php---------取汉字的第一个字的首字母
开发中用到的方法,取出第一个汉字的首字母: /** * 取汉字的第一个字的首字母 * @param string $str * @return string|null */ function getF ...
- HDU 1045 dfs + 回溯
题目链接:http://acm.hrbust.edu.cn/vj/index.php?/vj/index.php?c=&c=contest-contest&cid=134#proble ...
- SGU 132. Another Chocolate Maniac 状压dp 难度:1
132. Another Chocolate Maniac time limit per test: 0.25 sec. memory limit per test: 4096 KB Bob real ...
- 源码编译运行android emulator
source buile/envsetup.sh lunch sdk-eng make sdk -j2 编译完之后,sdk安装在了下面的目录里 ANDROIID_DIR/out/host/linux- ...
- SSRS实现 矩阵列实现动态列
需求背景:按区域查询店铺的销售量和库存量,然后店铺的数据是动态的.实现类似效果如下图,其中蓝色框是动态的,店铺的数量是不确定的,可能是3个,也可能是20个. 步骤一: 步骤二: 加工后: 最后效果:
- PostgreSQL常用插件收集
hexdump -C 数据表文件 -- 查看表文件中数据. pg_stat_statements pgcompacttable -- 在减少锁的情况下,清理表和索引的老空间. pg_repack--P ...