你可以自定义的等级栏
1只让XML文件在你绘制的文件夹并将其命名为rating_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/rating_empty" />
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/rating_empty" />
<item android:id="@android:id/progress" android:drawable="@drawable/rating_filled" />
</layer-list>
2使另一绘制XML文件,并将其命名为rating_empty.xml
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_unrated_star" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_unrated_star" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_unrated_star" />
<item android:drawable="@drawable/ic_unrated_star" />
3做出充满明星并将其命名为rating_filled.xml
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_rated_star" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_rated_star" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_rated_star" />
<item android:drawable="@drawable/ic_rated_star" />
4转到你的价值观文件夹,打开anothe绘制xml文件style.xml并添加样式
<style name="customRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/rating_bar</item>
</style>
5只使用自定义的评价吧,你刚才创建
<RatingBar
style="@style/customRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:numStars="5" />
注意:ic_rated_star和ic_unrated_star是完全地充满星级和空的星图像,你想要显示在你的评级栏。
希望这对你有用...祝你好运...
试过给风格?风格= “机器人:ATTR/ratingBarStyle”? –
@Viren我正在设置自定义评级栏。 –
我没有得到你。你正在创建自定义风格?我告诉你在你放置评级栏的xml中声明它。 –