[英]Android Rating bar Invisible
Below is my code for the rating bar以下是我的评分栏代码
<RatingBar
android:id="@+id/ratingBarU"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_weight="1"
android:numStars="10"
android:progressTint="#FBE140"
android:stepSize="1" />
The problem I encounter is that, when I set the style to,我遇到的问题是,当我将样式设置为时,
style="?android:attr/ratingBarStyleSmall"
The rating bar gets invisible评分栏变得不可见
and when I try当我尝试
style="?android:attr/ratingBarStyleIndicator"
The rating bar shows all 10 stars but they are un-clickable when run on my emulator.评分栏显示所有 10 颗星,但在我的模拟器上运行时无法点击。 All I want is for my rating bar to show all 10 stars and fit to the screen size Please help !
我想要的只是让我的评分栏显示所有 10 颗星并适合屏幕尺寸请帮助! Im very new to android development
我对 android 开发非常陌生
Think are you using inside the LinearLayout(Horizontal) .想想你在LinearLayout(Horizontal)内使用。 Can you please use this code in vertical linearlayout
你能在垂直线性布局中使用这个代码吗
<RatingBar
android:id="@+id/ratingBarU"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyleIndicator"
android:numStars="10"
android:progressTint="#FBE140"
android:stepSize="1" />
Make layout_height
wrap_content don't use a specific dp value, also I didn't understand why you have used layout_weight
as you are setting a specific height of 45dp
(it should be wrap_content) and setting width as wrap_content.使
layout_height
wrap_content不使用特定的 dp 值,我也不明白您为什么使用layout_weight
,因为您将特定高度设置为45dp
(它应该是 wrap_content)并将宽度设置为 wrap_content。 Your rating bar should be look like this您的评分栏应如下所示
<RatingBar
android:id="@+id/ratingBarU"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="10"
android:progressTint="#FBE140"
android:stepSize="1" />
Output Output
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.