当前位置:网站首页>Functions and usage of ratingbar
Functions and usage of ratingbar
2022-07-07 17:36:00 【XLMN】
Ratingbar The function and usage of
Star rating bar
The star rating bar and the drag bar have the same parent absSeekBar
RatingBar and Seekbar( Drag bar ) The biggest difference is ,RatingBar Show progress by stars
android:max=“255” Set progress bar maximum
android:numStars="5" Set the progress bar to a total of several stars
android:progress="255" Set the default maximum value
android:stepSize=“0.5” Set the minimum number of stars to change each time
ratingbar Itself is a special progressbar( Progress bar )
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);
// Binding event listening
rb.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
// TODO Auto-generated method stub
// Dynamically change the transparency of the picture , among 255 Is the maximum value of star rating bar
//5 Stars represent the maximum 255
//setImageAlpha Set transparency
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" />
<!--
Define a star rating bar , Change the transparency of the picture android:max="255" Set progress bar maximum
android:numStars="5" Set the progress bar to a total of several stars
android:progress="255" Set the default maximum value
android:stepSize="0.5" Set the minimum number of stars to change each time
-->
<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" />
![ Insert picture description here ](https://img-blog.csdnimg.cn/5c7dde1a405e4b3c8bb3d2467032dacc.png) 边栏推荐
- 【网络攻防原理与技术】第5章:拒绝服务攻击
- 麒麟信安操作系统衍生产品解决方案 | 存储多路径管理系统,有效提高数据传输可靠性
- 【信息安全法律法規】複習篇
- 让保险更“保险”!麒麟信安一云多芯云桌面中标中国人寿, 助力金融保险信息技术创新发展
- 【重新理解通信模型】Reactor 模式在 Redis 和 Kafka 中的应用
- 99%的人都不知道|私有化部署还永久免费的即时通讯软件!
- Flask搭建api服务
- Leetcode brush questions day49
- Solid function learning
- A tour of grpc:03 - proto serialization / deserialization
猜你喜欢
随机推荐
跟奥巴马一起画方块(Lua)
SlashData开发者工具榜首等你而定!!!
本周小贴士#135:测试约定而不是实现
本周小贴士#140:常量:安全习语
SIGGRAPH 2022最佳技术论文奖重磅出炉!北大陈宝权团队获荣誉提名
Proxmox VE重装后,如何无损挂载原有的数据盘?
redis主从、哨兵主备切换搭建一步一步图解实现
Skimage learning (3) -- adapt the gray filter to RGB images, separate colors by immunohistochemical staining, and filter the maximum value of the region
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
Notes on installing MySQL in centos7
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
服务器彻底坏了,无法修复,如何利用备份无损恢复成虚拟机?
【网络攻防原理与技术】第3章:网络侦察技术
企业即时通讯软件是什么?它有哪些优势呢?
第3章业务功能开发(用户登录)
Establishment of solid development environment
【网络攻防原理与技术】第6章:特洛伊木马
国内首创!Todesk将RTC技术融入远程桌面,画质更清晰操作更流畅
命令模式 - Unity
本周小贴士#136:无序容器