1

i have implemented android native rating bar but when i set number of star to 10 it will cut from the end of the screen its happening in some devices can anybody help me how can i manage to display 10 star consistently on all mobile devices?

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_marginBottom="@dimen/_15sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content">


<TextView
    android:id="@+id/tValueLabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="@dimen/_5sdp"
    android:textSize="@dimen/_11ssp" />



<RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="?android:attr/ratingBarStyleIndicator"
    android:isIndicator="false"
    android:layout_marginTop="@dimen/_5sdp"
    android:stepSize="1.0" />


</LinearLayout>
Android
  • 11
  • 3

3 Answers3

0

try this to minimize size of stars

android:scaleX=".4"
android:scaleY=".4" 

I hope it will work with you

0

your RatingBar is cutting from end due to no space in screen to fit 10 star. Solution for it is to reduce the size of star. there is no direct method by which we can reduce size of star. In your case scaleX and scaleY will works. Pls use below code for RatingBar

<RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="?android:attr/ratingBarStyleIndicator"
    android:isIndicator="false"
    android:scaleX=".8"
    android:scaleY=".8"
    android:translationX="-10dp"
    android:layout_marginTop="5dp"
    android:stepSize="1.0" />
Manish
  • 1,071
  • 2
  • 10
  • 27
0

Make changes to your width parameter as per your need:

android:layout_width="xx dp"

Prajwal Waingankar
  • 2,534
  • 2
  • 13
  • 20