当前位置:网站首页>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) 边栏推荐
- 鲲鹏开发者峰会2022 | 麒麟信安携手鲲鹏共筑计算产业新生态
- 【网络攻防原理与技术】第6章:特洛伊木马
- 【TPM2.0原理及应用指南】 9、10、11章
- VSCode关于C语言的3个配置文件
- 【TPM2.0原理及应用指南】 16、17、18章
- 【分布式理论】(一)分布式事务
- Is AI more fair than people in the distribution of wealth? Research on multiplayer game from deepmind
- Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
- 【饭谈】Web3.0到来后,测试人员该何去何从?(十条预言和建议)
- 本周小贴士#134:make_unique与私有构造函数
猜你喜欢
随机推荐
Rpcms method of obtaining articles under the specified classification
第2章搭建CRM项目开发环境(搭建开发环境)
字符串 - string(Lua)
本周小贴士#140:常量:安全习语
【网络攻防原理与技术】第6章:特洛伊木马
麒麟信安携异构融合云金融信创解决方案亮相第十五届湖南地区金融科技交流会
Nerf: the ultimate replacement for deepfake?
How to implement safety practice in software development stage
Sator launched Web3 game "satorspace" and launched hoobi
How to mount the original data disk without damage after the reinstallation of proxmox ve?
策略模式 - Unity
【可信计算】第十次课:TPM密码资源管理(二)
第2章搭建CRM项目开发环境(数据库设计)
如何在软件研发阶段落地安全实践
The server is completely broken and cannot be repaired. How to use backup to restore it into a virtual machine without damage?
alertDialog創建对话框
命令模式 - Unity
L1-025 正整数A+B(Lua)
99% 用户在 Power BI 云端报表常犯错误
请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取