gpt4 book ai didi

java - 带有 5 个进度条的评级进度图表

转载 作者:行者123 更新时间:2023-12-02 01:46:17 25 4
gpt4 key购买 nike

我需要为我在应用程序上的评论绘制评级图表。分别为每个星星,如 1、2、3、4 和 5。作为引用,我上传了一张图片,请建议我 n=最佳方式。 enter image description here

最佳答案

您好,您可以执行如下操作,例如获取 5 个 RatingBar 和 5 个 ProgressBar。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">

<RatingBar
android:id="@+id/rating_5"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="5"
android:rating="5" />

<ProgressBar
android:id="@+id/progress_5"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/rating_5"
android:progress="50" />

<RatingBar
android:id="@+id/rating_4"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_5"
android:layout_alignRight="@+id/rating_5"
android:isIndicator="true"
android:numStars="4"
android:rating="4" />

<ProgressBar
android:id="@+id/progress_4"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_5"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/rating_5"
android:progress="50" />


<RatingBar
android:id="@+id/rating_3"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_4"
android:layout_alignRight="@+id/rating_5"
android:isIndicator="true"
android:numStars="3"
android:rating="3" />

<ProgressBar
android:id="@+id/progress_3"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_4"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/rating_5"
android:progress="30" />


<RatingBar
android:id="@+id/rating_2"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_3"
android:layout_alignRight="@+id/rating_5"
android:isIndicator="true"
android:numStars="2"
android:rating="2" />

<ProgressBar
android:id="@+id/progress_2"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_3"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/rating_5"
android:progress="20" />


<RatingBar
android:id="@+id/rating_1"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_2"
android:layout_alignRight="@+id/rating_5"
android:isIndicator="true"
android:numStars="1"
android:rating="1" />

<ProgressBar
android:id="@+id/progress_1"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rating_2"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/rating_5"
android:progress="10" />

</RelativeLayout>

这是输出:

Rating Image

希望对您有帮助。谢谢。

关于java - 带有 5 个进度条的评级进度图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53649979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com