Small Style Custom rating bar (readonly custom rating bar)

倾然丶 夕夏残阳落幕 提交于 2020-01-04 12:43:12

问题


I tried to create a custom rating bar. I don't use style because I only use this once. So, I created a layer-list in the drawable folder (its name is custom_rating_bar.xml):

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item
    android:id="@android:id/background"
    android:drawable="@drawable/custom_icon_empty"/>
  <item
    android:id="@android:id/secondaryProgress"
    android:drawable="@drawable/custom_icon_empty"/>
  <item
    android:id="@android:id/progress"
    android:drawable="@drawable/custom_icon"/>
</layer-list>

And I use this code in the rating bar to use those icons:

android:progressDrawable="@drawable/custom_rating_bar"

My image size is standard (48x48 for mdpi, etc) and i use a small style rating bar :

style="?android:attr/ratingBarStyleSmall"

The problem is, i cant use style="?android:attr/ratingBarStyleSmall" together with android:progressDrawable (When i did this, the images will not shown). When i delete the style (style="?android:attr/ratingBarStyleSmall") my rating bar become too big (the images are shown).

This image show how big is it (i think the margin between image is also too much) :

So, how to make my custom rating bar smaller? (as small as the default small style rating bar).

And this custom rating bar is for show only (cant be changed by user).

Thanks.


回答1:


First off, remove the "+"s from your android:id. Also, you may want to add a style in your xml, such as style="?android:attr/progressBarStyleHorizontal" depending on your needs. You might also need to use android:indeterminateDrawable="@drawable/custom_rating_bar" instead of progressDrawable



来源:https://stackoverflow.com/questions/14251092/small-style-custom-rating-bar-readonly-custom-rating-bar

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