How to make RatingBar to show five stars

前端 未结 18 539
栀梦
栀梦 2020-12-04 18:58

I am following the standard example of how to add a RatingBar. To control the number of stars I tried to use android:numStars=\"5\". The problem is

18条回答
  •  时光取名叫无心
    2020-12-04 19:29

    I'm also facing the problem that exceeding the stars than specified no of stars. For this, we don't want worry about whatever the layout type either relative or linear layout. Simply use the width as follows:

    ratingBar.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    


    Please avoid using match_parent and fill_parent for ratingbar.
    Hope the things would be helpful.

提交回复
热议问题