Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid RatingBar - a complete mess
    text
    copied!<p>I know this is going to sound ranty, but it just feels like Android's UI components and behaviours are off the wall sometimes.</p> <p>Consider the following XML:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;RatingBar android:id="@+id/ratingBar1" android:style="@android:style/Widget.Holo.Light.RatingBar.Small" android:progress="3" android:max="5" android:numStars = "5" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Screenshots of how that would look on different device sizes:</p> <p><img src="https://i.stack.imgur.com/toiAv.png" alt="Nexus S rating bar"> Nexus S rating bar</p> <p><img src="https://i.stack.imgur.com/uDXRs.png" alt="Tablet rating bar"> Tablet rating bar</p> <p><img src="https://i.stack.imgur.com/0IowB.png" alt="Small Device rating bar"> Small Device rating bar</p> <p>Even though it's only in the preview tool, I can confirm that's actually how it looks on the devices.</p> <p>The small device behaviour is maddening. How does a RatingBar that specifies 5 stars only get 3 displayed, why not scale down the stars to fit in the window? </p> <p>Thinking the wrap_content width was the issue, I switched to layout_width="fill_parent" and that didn't change the look on a small device, but it completely messed up on Tablets (so much for "numStars" of 5):</p> <p><img src="https://i.stack.imgur.com/t0mEv.png" alt="Tablet with fill_parent for width"></p> <p>My question is, is there a way to get proper behaviour for the RatingBar in terms of sizing? You would think the numStars or max would be sufficient but it's completely arbitrary. When the RatingBar is stretched so that it draws more stars, it adds stars and see how with a progress of 3, it draws it according to the number of stars displayed? It doesn't make sense not to adhere to numStars!</p> <p>If there is no way to get logical performance from the RatingBar, are there any alternatives including 3rd party widgets? If not, I guess I could always draw 5 ImageViews and just rig it to perform accordingly.</p> <p>(Keep in mind all this behaviour was exhibited with just one RatingBar in the layout - forget trying to size with other widgets/components, or utilizing your own styles. I know it's been done, but why is this the default behavior?)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload