<?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 星级评分条的更多相关文章

  1. 更改星级评分条 RatingBar 的样式

    1.首先在布局中引用星级评分条: <RatingBar            android:id="@+id/room_ratingbar"            styl ...

  2. Android 自学之星级评分条RatingBar

    星级评分条(RatingBar)与拖动条十分相似,他们还有共同的父类AbsSeekBar.实际上星级评分条和拖动条的用法和功能都十分的接近:他们都允许用户通过拖动来改变进度.RatingBar与See ...

  3. Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar

    原文:Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar 前面两期都在学习ProgressBar的使用,关于自定义ProgressBar的内容后期会继续学习的,本期先 ...

  4. ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)

    1.ProgressBar(进度条) (1)介绍 (2)常用属性 (3)xml代码 <ProgressBar android:id="@+id/progressBar2" s ...

  5. 星级评分条(RatingBar)的功能和用法

    星级评分条与拖动条有相同的父类:AbsSeekBar,因此它们十分相似.实际上星级评分条与拖动条的用法.功能都十分接近:它们都是允许用户通过拖动条来改变进度.RatingBar与SeekBar最大区别 ...

  6. 星级评分条(RatingBar)的功能与用法

    星级评分条与拖动条有相同的父类:AbsSeekBar,因此它们十分相似.实际上星际评分条与拖动条的用法.功能都十分接近:它们都允许用户通过拖动来改变进度.RatingBar与SeekBar的最大区别在 ...

  7. android 评分条 RatingBar 使用及自定义

    一.先上效果图片: 第一个是自定义: 第二个是原生的: 二.atingBar 介绍: RatingBar是基于SeekBar和ProgressBar的扩展,用星型来显示等级评定.使用RatingBar ...

  8. 7.Android之评分条RatingBar和拖动条SeekBar学习

    评分条RatingBar和拖动条SeekBar很常见,今天来学习下. (1)RatingBar评分条 如图: <RelativeLayout xmlns:android="http:/ ...

  9. android评分条RatingBar自定义设置

    RatingBar为评分条控件,默认效果为若干个绿色的星星,如果想将其换成其他自定义图片就要自定义它的style.首先是布局文件: 其中android:numStars="5"设置 ...

随机推荐

  1. centos7安装redis 并配置在后台启动

    官网  https://redis.io/download 先进入 目录 /usr/local 1 下载文件包 $ wget http://download.redis.io/releases/red ...

  2. Vue项目中自动将px转换为rem

    一.配置与安装步骤: 1.在 Vue 项目的 src 文件夹下创建一个 config 文件夹: 2.在 config 文件夹中创建 rem.js: 3.将以下代码复制到 rem.js 中: // 基准 ...

  3. mysql开发相关

    1.mysql事务原理,特性,事务并发控制2.如何解决高并发场景下的插入重复3.乐观锁和悲观锁4.常用数据库引擎之间区别5.mysql索引6.B-Tree7.mysql索引类型8.什么时候创建索引9. ...

  4. 创建数据库表时,如何设置mysql中时间的默认值

    应用场景: 1.在数据表中,要记录每条数据是什么时候创建的,不需要应用程序去特意记录,而由数据数据库获取当前时间自动记录创建时间: 2.在数据库中,要记录每条数据是什么时候修改的,不需要应用程序去特意 ...

  5. 《代码敲不队》第九次团队作业:Beta冲刺第2天

    项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 作业链接地址 团队名称 代码敲不队 作业学习目标 (1)项目文档的完善与整理:(2)团队项目总结陈述PPT编制:(3)符合 ...

  6. 更改intellij高亮字体背景颜色

    intellij工具中依次进入file -> settings -> editor -> colors & fonts -> general,在右侧窗口中将result ...

  7. c99的新功能

    在ANSI的标准确立后,C语言的规范在一段时间内没有大的变动,然而C++在自己的标准化创建过程中继续发展壮大.<标准修正案一>在1994年为C语言创建了一个新标准,但是只修正了一些C89标 ...

  8. python - django authenticate 返回结果一直是None

    # 不论怎么测试 authenticate 返回结果一直是None,查了查原因好像是 django 2.1 版本的问题 ( 我用的是 2.1.7) 解决方法: 1. 先导入 from django.c ...

  9. httpclient: 设置请求的超时时间,连接超时时间等

    httpclient: 设置请求的超时时间,连接超时时间等 public static void main(String[] args) throws Exception{ //创建httpclien ...

  10. IDEA快速实现接口快捷方式

    IDEA快速实现接口快捷方式 ALT +INSERT