当前位置:网站首页>Ratingbar的功能和用法
Ratingbar的功能和用法
2022-07-07 15:40:00 【XLMN】
Ratingbar的功能和用法
星级评分条
星级评分条和拖动条有相同的父类absSeekBar
RatingBar和Seekbar(拖动条)的最大区别在于,RatingBar通过星星来表示进度
android:max=“255” 设置进度条最大值
android:numStars="5"设置进度条总共几个星级
android:progress="255"设置默认的最大值
android:stepSize=“0.5” 设置每次最少改变多少星级
ratingbar本身就是一个特殊的progressbar(进度条)
public class MainActivity extends Activity {
ImageView iv;
RatingBar rb;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.ratingbar);
iv=(ImageView) findViewById(R.id.image);
rb=(RatingBar) findViewById(R.id.ratingbar);
//绑定事件监听
rb.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
// TODO Auto-generated method stub
//动态改变图片的透明度,其中255是星级评分条的最大值
//5个星星就代表最大值255
//setImageAlpha设置透明
iv.setImageAlpha((int) (arg1*255/5));
}
});
}
}
<?xml version="1.0" encoding="utf-8"?><ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="240dp"
android:src="@drawable/mia8" />
<!--
定义一个星级评分条,改变图片透明度 android:max="255" 设置进度条最大值
android:numStars="5"设置进度条总共几个星级
android:progress="255"设置默认的最大值
android:stepSize="0.5" 设置每次最少改变多少星级
-->
<RatingBar
android:id="@+id/ratingbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:max="255"
android:numStars="5"
android:progress="255"
android:stepSize="0.5" />
 边栏推荐
- 使用 xml资源文件定义菜单
- 【信息安全法律法規】複習篇
- [source code interpretation] | source code interpretation of livelistenerbus
- [fan Tan] those stories that seem to be thinking of the company but are actually very selfish (I: building wheels)
- [Huang ah code] Why do I suggest you choose go instead of PHP?
- [video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
- DatePickerDialog和trimepickerDialog
- The top of slashdata developer tool is up to you!!!
- 【TPM2.0原理及应用指南】 12、13、14章
- 99% 用户在 Power BI 云端报表常犯错误
猜你喜欢
Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism

麒麟信安中标国网新一代调度项目!

简单的loading动画

第2章搭建CRM项目开发环境(搭建开发环境)

PLC:自动纠正数据集噪声,来洗洗数据集吧 | ICLR 2021 Spotlight

策略模式 - Unity

How to add aplayer music player in blog

Lex & yacc of Pisa proxy SQL parsing

第3章业务功能开发(安全退出)

redis主从、哨兵主备切换搭建一步一步图解实现
随机推荐
alertDialog創建对话框
[Seaborn] combination chart: facetgrid, jointgrid, pairgrid
LeetCode1051(C#)
99% of users often make mistakes in power Bi cloud reports
麒麟信安操作系统衍生产品解决方案 | 存储多路径管理系统,有效提高数据传输可靠性
【可信计算】第十次课:TPM密码资源管理(二)
《世界粮食安全和营养状况》报告发布:2021年全球饥饿人口增至8.28亿
Jenkins发布uniapp开发的H5遇到的问题
[source code interpretation] | source code interpretation of livelistenerbus
使用Stace排除故障的5种简单方法
服务器彻底坏了,无法修复,如何利用备份无损恢复成虚拟机?
【信息安全法律法规】复习篇
SIGGRAPH 2022最佳技术论文奖重磅出炉!北大陈宝权团队获荣誉提名
The computer cannot add a domain, and the Ping domain name is displayed as the public IP. What is the problem? How to solve it?
Solidity函数学习
让保险更“保险”!麒麟信安一云多芯云桌面中标中国人寿, 助力金融保险信息技术创新发展
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
VSCode关于C语言的3个配置文件
Test case management tool recommendation
Sator launched Web3 game "satorspace" and launched hoobi