问题描述
我试图创建一个自定义的评价吧。我不使用风格
,因为我只用一次。所以,我在绘制
文件夹(它的名字是 custom_rating_bar创建一个
)图层列表
。 XML
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>
和我用这个code的评比栏使用这些图标:
And I use this code in the rating bar to use those icons:
android:progressDrawable="@drawable/custom_rating_bar"
我的图像大小为标准(48×48适用于mdpi等),我使用的小风格的评价吧:
style="?android:attr/ratingBarStyleSmall"
问题是,我不能使用风格=机器人:ATTR / ratingBarStyleSmall
与安卓在一起:progressDrawable
(当我这样做,图像将未显示)。当我删除样式(风格=机器人: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).
感谢。
推荐答案
首先,从Android删除+S:ID。此外,您可能要添加在XML风格,如 =风格:根据您的需求
机器人ATTR / progressBarStyleHorizontal?。您可能还需要使用的android:indeterminateDrawable =@绘制/ custom_rating_bar
而不是progressDrawable
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
这篇关于小风格的自定义等级栏(只读自定义的等级吧)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!