首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓10星评级条

安卓10星评级条
EN

Stack Overflow用户
提问于 2019-11-26 15:54:00
回答 5查看 452关注 0票数 0

我的要求是打开一个允许用户对内容进行评分的对话框,该对话框中有10颗星。我尝试了不同的方法,但都不起作用。下面是我的rating_dialog.xml文件

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:background="@color/colorWhite"
    android:orientation="vertical">
        <RatingBar
            android:id="@+id/dialog_rating_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="?android:attr/ratingBarStyleSmall"
            android:layout_marginTop="@dimen/margin_15"
            android:layout_gravity="center"
            android:layout_marginEnd="@dimen/margin_30"
            android:progressBackgroundTint="@color/colorHint"
            android:progressTint="@color/color_orange"
            android:secondaryProgressTint="@color/color_orange"
            android:numStars="10"
            android:scaleX="1.8"
            android:scaleY="1.8" />
</LinearLayout>

它只显示9星,评级栏布局也不正确。任何帮助都是非常感谢的。谢谢!

EN

回答 5

Stack Overflow用户

发布于 2019-11-26 16:23:07

你可以这样尝试。Working for me用bottom打开

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

        <TextView
                android:layout_width="match_parent"
                android:layout_height="62dp"
                android:gravity="center_horizontal"
                android:padding="@dimen/_10sdp"
                android:text="@string/str_rate_this"
                android:textSize="@dimen/_15sdp" />

        <RatingBar
                style="@style/Widget.AppCompat.RatingBar.Indicator"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:numStars="10"
                android:rating="5"
                android:layout_gravity="center_horizontal"
                android:isIndicator="false"
android:scaleX=".9"
            android:scaleY=".9"
                android:stepSize="1" />

        <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/rectangle_background"
                android:layout_margin="@dimen/_20sdp"
                android:text="Rate now" />

    </LinearLayout>
票数 4
EN

Stack Overflow用户

发布于 2019-11-26 16:27:19

尝尝这个,

代码语言:javascript
复制
   <RatingBar
        android:id="@+id/dialog_rating_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/ratingBarStyleSmall"
        android:layout_marginTop="@dimen/margin_15"
        android:layout_gravity="center"
        android:layout_marginEnd="@dimen/margin_30"
        android:layout_marginStart="@dimen/margin_30"
        android:progressBackgroundTint="@color/colorHint"
        android:progressTint="@color/color_orange"
        android:secondaryProgressTint="@color/color_orange"
        android:numStars="10"
        android:scaleX="1.8"
        android:scaleY="1.2" />

为了适应这颗星,我将scaleY降低到了1.2。

票数 0
EN

Stack Overflow用户

发布于 2019-11-26 16:28:41

你已经给你的根LinearLayout指定了android:layout_width="300dp",这就是为什么它没有显示10星的原因。

要使其正常工作,您需要根据您的需求为其提供match_parentwrap_content

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59046122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档