ratingBar 星级评分条

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="240dp"
android:src="@drawable/lijiang"/>
<!-- 定义一个星级评分条 -->
<RatingBar
android:id="@+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:max="255"
android:progress="255"
android:stepSize="0.5"/>
</LinearLayout>
主界面
val image = findViewById<ImageView>(R.id.image)
val ratingBar = findViewById<RatingBar>(R.id.rating)
ratingBar.onRatingBarChangeListener = RatingBar.OnRatingBarChangeListener { ratingBar, rating, fromUser ->
// 当星级评分条的评分发生改变时触发该方法
// 动态改变图片的透明度,其中255是星级评分条的最大值
// 5个星星就代表最大值255
image.imageAlpha = (rating * 255 / 5).toInt()
print(rating)
}
主程序
ratingBar 星级评分条的更多相关文章
- 更改星级评分条 RatingBar 的样式
1.首先在布局中引用星级评分条: <RatingBar android:id="@+id/room_ratingbar" styl ...
- Android 自学之星级评分条RatingBar
星级评分条(RatingBar)与拖动条十分相似,他们还有共同的父类AbsSeekBar.实际上星级评分条和拖动条的用法和功能都十分的接近:他们都允许用户通过拖动来改变进度.RatingBar与See ...
- Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar
原文:Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar 前面两期都在学习ProgressBar的使用,关于自定义ProgressBar的内容后期会继续学习的,本期先 ...
- ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)
1.ProgressBar(进度条) (1)介绍 (2)常用属性 (3)xml代码 <ProgressBar android:id="@+id/progressBar2" s ...
- 星级评分条(RatingBar)的功能和用法
星级评分条与拖动条有相同的父类:AbsSeekBar,因此它们十分相似.实际上星级评分条与拖动条的用法.功能都十分接近:它们都是允许用户通过拖动条来改变进度.RatingBar与SeekBar最大区别 ...
- 星级评分条(RatingBar)的功能与用法
星级评分条与拖动条有相同的父类:AbsSeekBar,因此它们十分相似.实际上星际评分条与拖动条的用法.功能都十分接近:它们都允许用户通过拖动来改变进度.RatingBar与SeekBar的最大区别在 ...
- android 评分条 RatingBar 使用及自定义
一.先上效果图片: 第一个是自定义: 第二个是原生的: 二.atingBar 介绍: RatingBar是基于SeekBar和ProgressBar的扩展,用星型来显示等级评定.使用RatingBar ...
- 7.Android之评分条RatingBar和拖动条SeekBar学习
评分条RatingBar和拖动条SeekBar很常见,今天来学习下. (1)RatingBar评分条 如图: <RelativeLayout xmlns:android="http:/ ...
- android评分条RatingBar自定义设置
RatingBar为评分条控件,默认效果为若干个绿色的星星,如果想将其换成其他自定义图片就要自定义它的style.首先是布局文件: 其中android:numStars="5"设置 ...
随机推荐
- sqlite3入门之sqlite3_get_table,sqlite3_free_table
sqlite3_get_table sqlite3_get_table函数原型: int sqlite3_get_table( sqlite3 *db, /* An open database */ ...
- LabelEncoder save 离线使用
For me the easiest way was exporting LabelEncoder as .pkl file for each column. You have to export t ...
- # Spring Boot & thymeleaf模板 使用 th:each 遍历对象数组 -生成一批html标签体
在controller中取出emps 对象数组 //1.查询所有的员工,返回列表页面 @GetMapping("/emps") public String list(Model m ...
- mac pro下安装brew软件包管理工具
Homebrew简称brew,OSX上的软件包管理工具,在Mac终端可以通过brew安装.更新.卸载软件. 1.打开终端直接输入下面指令回车: ruby -e "$(curl -fsSL h ...
- Union-Find(并查集): Dynamic Connectivity 问题
设计算法一般所使用的方法过程 什么是Dynamic connectivity 我们的problem就是支持这两种操作: Union与connected query Example 问题是两个objec ...
- 复杂Java对象所占内存的大小
我们在Java单个对象内存布局中讲解了单个简单的Java对象所占内存的大小的计算.那么这篇文章主要是讲解复杂Java对象所占内存大小的计算,我们把继承.复合的对象称为复杂对象 继承对象 class P ...
- indexOf()、lastIndexOf()、startsWith()等方法应用
- (转载) 从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)
安装完之后别忘了还需要安装SSMS,这是坑爹的地方之二,干嘛不集成到SQL Server安装包里还要用户自己单独下载 下载地址:https://msdn.microsoft.com/en-us/lib ...
- 数据库基准测试标准 TPC-C or TPC-H or TPC-DS
针对数据库不同的使用场景TPC组织发布了多项测试标准.其中被业界广泛接受和使用的有TPC-C .TPC-H和TPC-DS. TPC-C: Approved in July of 1992, TPC B ...
- QMutexLocker基于QMutex的便利类
首先需要注意的是:QMutexLocker这个类是基于QMutex的便利类,这个类不能够定义 私有成员变量 和 全局变量,只能够定义局部变量来使用. 使用方法:(1)先定义一个QMutex类的 ...