【问题标题】:RatingBar incorrectly selectedRatingBar 选择不正确
【发布时间】:2021-04-19 15:39:12
【问题描述】:
<LinearLayout>
    ...
    <androidx.appcompat.widget.AppCompatRatingBar
        android:id="@+id/starRatingBar"
        style="@style/yellowStarRatingBar"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/dp_10"
        android:layout_weight="0.5"
        android:numStars="5"
        android:rating="0"
        android:stepSize="1" />
    ...
</LinearLayout>

当我点击右半边的??????,下一个????也被选中。有谁知道是怎么回事?

【问题讨论】:

标签: android ratingbar


【解决方案1】:

此外,如果您设置 layout_weight,这将取代 numStars 属性。

  <RatingBar
                android:id="@+id/starRatingBar"
                style="@style/yellowStarRatingBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                style="?android:attr/ratingBarStyleSmall"
                android:numStars="5"
                android:rating="0"
                android:stepSize="1" />

【讨论】:

  • 目的是让用户手动选择评分。
  • 看看我的回答。我认为重量正在打断 Ratingbar
  • weight=0.5 因为还有其他元素
  • 我会尽力帮助你。我找到了这篇文章。可能它会帮助你。 stackoverflow.com/questions/33584058/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-17
  • 2021-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-07
相关资源
最近更新 更多