I am having problems when trying to use multiple horizontal images on different size devices. I have 7 separate Ratingbars, each using a different custom image. I have scaled all the images and placed them into their respective dpi drawable folders. The problem I'm having is that on the xlarge mdpi screen (top left of the image below), they fit perfectly, but when I'm viewing them on a smaller screens, the entire 7 ratingbars are too wide to fit within the bounds of the device, as shown below:
I have followed the correct scaling for the images (based on the original base size of the mdpi) as stated in the following answer: https://stackoverflow.com/a/11581786/1634369
ldpi | mdpi | tvdpi | hdpi | xhdpi | xxhdpi | xxxhdpi
0.75 | 1 | 1.33 | 1.5 | 2 | 3 | 4
Based on the scaling above, the following are all my drawable folders, showing the dimensions of each of the images within their respective dpi folders (all based off the mdpi ratio):
Then in order to display each of the Ratingbars, I set up a selector for each rating bar which will use a default grey image and a coloured image based on the rating value. The following shows the code I use to display each of the Ratingbars using the layout. NOTE: I have based the width and height from the base mdpi values.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RatingBar
android:numStars="1"
android:rating="1"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="75dp"
android:layout_height="77dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_a" />
<RatingBar
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="73dp"
android:layout_height="114dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_b" />
<RatingBar
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="63dp"
android:layout_height="132dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_c" />
<RatingBar
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="79dp"
android:layout_height="145dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_d" />
<RatingBar
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="79dp"
android:layout_height="161dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_e" />
<RatingBar
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="108dp"
android:layout_height="168dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_f" />
<RatingBar
android:numStars="1"
android:rating="0.5"
android:stepSize="0.01"
android:isIndicator="true"
android:layout_width="147dp"
android:layout_height="189dp"
android:layout_gravity="bottom"
android:gravity="bottom"
android:progressDrawable="@drawable/selector_g" />
</LinearLayout>
Would anyone be able to help me ensure that no matter what screen the Ratingbars are displayed on and no matter what density the device is, it will always look the same (the way it looks on the 10.1 mdpi screen which is displayed top left of the image showing all the different screens? Any help would be greatly appreciated.
Thanks very much for taking the time to read through this question. I have placed the code on Github at the following location: https://github.com/gbayo1/RatingBarScalingIssue.git