zoukankan      html  css  js  c++  java
  • 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)
            }
    主程序
  • 相关阅读:
    数据结构笔记
    并查集
    计算两个数的最大公约数和最小公倍数
    行盒
    浏览器兼容性和布局
    Java中HashMap等的实现要点浅析
    关于js异步上传文件
    填充路径时所使用的 “非零环绕规则”
    XP极限编程
    假如森林里有一棵树倒下了
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/11519276.html
Copyright © 2011-2022 走看看