Using rating bar in android

有些话、适合烂在心里 提交于 2019-12-11 02:15:50

问题


I have a rating Bar

<RatingBar
            android:id="@+id/RATINGinitialvalueratingID"
            style="?android:attr/ratingBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/RATINGseekBarID"
            android:isIndicator="false"
            android:numStars="5" />

Say there are three stars in this .... i have two questions

  • How to show full stars all the time ?
  • How to disable editing of stars (static display of allocated rating)?

回答1:


Try to add the following attribute to show 5 stars:

android:rating="5"

Also, try to add those to make it not editable:

android:isIndicator="true"
android:focusable="false"
android:clickable="false"



回答2:


Try this..

RatingBar ratingBar = (RatingBar)findViewById(R.id.RATINGinitialvalueratingID);
ratingBar.setRating(5);
ratingBar.setFocusable(false);


来源:https://stackoverflow.com/questions/19206135/using-rating-bar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!