How to reduce the space around rating bar in android

前端 未结 3 2015
刺人心
刺人心 2020-12-22 02:55

I have included a rating bar in android, and now I need to place a text view to immediate right if the rating bar.But I failed to do the same since, there is a lot of unwant

相关标签:
3条回答
  • 2020-12-22 03:14

    You can use android default styles, Like:

    style="@android:style/Widget.Holo.Light.RatingBar.Small"
    

    in you xml layout. I am using above and have no space around it. You can check variants here

    0 讨论(0)
  • 2020-12-22 03:20

    While using the base style for the RatingBar, set the minHeight to 0dp. The base minHeight in the style itself was preventing the view from scaling down. Setting it to 0 should work as you expect a normal view (we set ours to wrap_content).


    Tried to use the base (@android:style/Widget.RatingBar) and small (@android:style/Widget.DeviceDefault.RatingBar.Small and @android:style/Widget.Holo.Light.RatingBar.Small) but both fixed/limited the size of the the RatingBar regardless of what icon is used. Looking at their codes, it was no surprise.

        <style name="Widget.RatingBar">
            <item name="indeterminateOnly">false</item>
            <item name="progressDrawable">@drawable/ratingbar_full</item>
            <item name="indeterminateDrawable">@drawable/ratingbar_full</item>
            <item name="minHeight">57dip</item>
            <item name="maxHeight">57dip</item>
            <item name="thumb">@null</item>
            <item name="mirrorForRtl">true</item>
        </style>
    
        <style name="Widget.Material.RatingBar.Small" parent="Widget.RatingBar.Small">
            <item name="progressDrawable">@drawable/ratingbar_small_material</item>
            <item name="indeterminateDrawable">@drawable/ratingbar_small_material</item>
            <item name="minHeight">16dp</item>
            <item name="maxHeight">16dp</item>
        </style>
    
        <style name="Widget.Holo.Light.RatingBar.Small" parent="Widget.RatingBar.Small">
            <item name="progressDrawable">@drawable/ratingbar_small_holo_light</item>
            <item name="indeterminateDrawable">@drawable/ratingbar_small_holo_light</item>
            <item name="minHeight">16dip</item>
            <item name="maxHeight">16dip</item>
        </style>
    

    Setting the scales didn't work right either.

    0 讨论(0)
  • 2020-12-22 03:30

    I tried to use different suggestion but i was unsuccessful with the Android Rating bar removal of extra padding. All i did downloaded ic icons from https://material.io/icons/ and use star and star bordered icon and programmed them with switch cases.

    0 讨论(0)
提交回复
热议问题