【问题标题】:Rating bar with custom size具有自定义大小的评分栏
【发布时间】:2018-05-18 23:15:39
【问题描述】:

我必须以我的自定义尺寸显示评分栏。但在我自定义大小的评分栏的情况下,星星在我的布局中消失了。我可以管理评级栏的填充大小和边距吗?

 <RatingBar
                    android:focusable="false"
                    android:id="@+id/rating_order"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:numStars="5"
                    android:stepSize="1.0"
                    android:scaleX="0.3"
                    android:scaleY="0.3" />

【问题讨论】:

标签: android android-layout


【解决方案1】:

您可以尝试从样式中设置参数:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="CustomRatingBar" parent="@android:style/Widget.RatingBar" >
 <item name="android:numStars">5</item>
 <item name="android:stepSize">1.0</item>
 <item name="android:layout_width">wrap_content</item>
 <item name="android:layout_height">wrap_content</item>
 <item name="android:paddingBottom">44dp</item>
 <item name="android:layout_marginLeft">4dp</item>
 <item name="android:layout_marginTop">4dp</item>
  </style>
<resources />

然后在你的RatingBar 中添加一个样式:

style="@style/CustomRatingBar"

【讨论】:

  • 谢谢。你给了我找到希望的答案的方法。我只是将样式父级更改为 @android:style/Widget.Material.RatingBar.Small 。这使我的问题。非常感谢先生。
  • 你知道我如何以编程方式设置每颗星或特定星的大小,比如 5 颗星中的第 3 颗吗?
猜你喜欢
  • 2012-12-24
  • 1970-01-01
  • 1970-01-01
  • 2015-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多