How to make a smaller RatingBar?

前端 未结 18 1422
情话喂你
情话喂你 2020-11-27 09:29

I\'ve added a RatingBar in a layout:



        
相关标签:
18条回答
  • 2020-11-27 09:38

    Use This Code

    <RatingBar
        android:id="@+id/ratingBarSmalloverall"
        style="?android:attr/ratingBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="30dp"
        android:isIndicator="false"
        android:numStars="5" />
    
    0 讨论(0)
  • 2020-11-27 09:41

    apply this.

    <RatingBar android:id="@+id/indicator_ratingbar"
        style="?android:attr/ratingBarStyleIndicator"
        android:layout_marginLeft="5dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical" />
    
    0 讨论(0)
  • 2020-11-27 09:44

    although answer of Farry works, for Samsung devices RatingBar took random blue color instead of the defined by me. So use

    style="?attr/ratingBarStyleSmall"
    

    instead.

    Full code how to use it:

    <android.support.v7.widget.AppCompatRatingBar
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="?attr/ratingBarStyleSmall" // use smaller version of icons
                    android:theme="@style/RatingBar"
                    android:rating="0"
                    tools:rating="5"/>
    
    <style name="RatingBar" parent="Theme.AppCompat">
            <item name="colorControlNormal">@color/grey</item>
            <item name="colorControlActivated">@color/yellow</item>
            <item name="android:numStars">5</item>
            <item name="android:stepSize">1</item>
        </style>
    
    0 讨论(0)
  • 2020-11-27 09:47

    Just use:

    android:scaleX="0.5"
    android:scaleY="0.5"
    

    Change the scale factor according to your need.

    In order to scale without creating a padding on the left also add

    android:transformPivotX="0dp"
    
    0 讨论(0)
  • 2020-11-27 09:47

    the small one implement by the OS

    <RatingBar
        android:id="@+id/ratingBar"
        style="?android:attr/ratingBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        />
    
    0 讨论(0)
  • 2020-11-27 09:49
    <RatingBar
        android:id="@+id/rating_bar"
        style="@style/Widget.AppCompat.RatingBar.Small"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    
    0 讨论(0)
提交回复
热议问题