<?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. yarn 错误There appears to be trouble with your network connection. Retrying...

    原因:yarn超时 解决途径:1.安装好后更换淘宝镜像 yarn config set registry https://registry.npm.taobao.org

  2. virtual box 6.0 扩容原有磁盘空间 ubuntu18.04

    virtual box 6.0 扩容原有磁盘空间 ubuntu18.04 1虚拟介质管理 1.1点击菜单 1.2 修改磁罗容量大小(需要关闭虚拟机),点击应用 2使用ubuntu安装镜像将新加容量添加 ...

  3. Git收藏

     Git Flow 的正确使用姿势 https://www.jianshu.com/p/41910dc6ef29 git合并分支上的commit为一条commit到master  https://ww ...

  4. Microsoft Onenote shortcuts / Onenote快捷键大全

    Onenote跟Libreoffice ,有道笔记比起来一个快捷键特别不太好用,就是Ctrl + Shift +v 并不会提供一个选择粘贴模式选项. 而在Onenote 中 Ctrl + Shift ...

  5. Linux命令基础1-环境介绍

    1.linux的简单历史 1)先有unix,后来有linux 2)linux操作系统是开源和免费的,里面的软件可能部分要收费 3)linux有不同发行版本,redhat,centos等. 4)1991 ...

  6. RANSEC算法

    移步:https://blog.csdn.net/u010128736/article/details/53422070 clc;clear;close all; %%%二维直线拟合 %%%生成随机数 ...

  7. 开放API接口安全处理

    一.开放API接口定义 顾名思义,开放出来给其他人调用的API接口就是开放API接口.例如,短信接口.邮件接口. 二.开放API的弱点 数据窃取 用户的密码等信息被不轨之人窃取,登录账号发布敏感信息, ...

  8. CSP 初赛 知识点整理

    BIOS: BIOS是英文"Basic Input Output System"的缩略词,直译过来后中文名称就是"基本输入输出系统".其实,它是一组固化到计算机 ...

  9. (尚013)Vue的生命周期

    三个阶段: 一.初始化显示; 二:更新显示 三.死亡 每一个阶段都对应生命周期的回调函数(也叫勾子函数) 生命周期图示: 1. 2.test013.html <!DOCTYPE html> ...

  10. codevs 4014EZ系列

    4014 EZ系列之丁畅大大打小怪兽   题目描述 Description 丁畅大大除了喜欢吃鸡腿和番茄炒鸡蛋,还喜欢变成奥特曼去打小怪兽. 有一天,他遇到了迪迦!!!!!!!!!!!!!!!!!!! ...