我尝试创建一个自定义评级栏。我不使用style
因为我只用过一次。所以,我创建了一个layer-list
in the drawable
文件夹(其名称是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>
我在评级栏中使用此代码来使用这些图标:
android:progressDrawable="@drawable/custom_rating_bar"
我的图像尺寸是标准的(mdpi 为 48x48 等),我使用small风格评价栏:
style="?android:attr/ratingBarStyleSmall"
问题是,我无法使用style="?android:attr/ratingBarStyleSmall"
和...一起android:progressDrawable
(当我这样做时,图像将不会显示)。当我删除样式时(style="?android:attr/ratingBarStyleSmall"
)我的评级栏变得太大(显示图像)。
This image show how big is it (i think the margin between image is also too much) :
So, 如何使我的自定义评分栏变小?(与默认的小样式评级栏一样小)。
这个自定义评级栏是仅供展示(用户无法更改)。
Thanks.
首先,从你的 android:id 中删除“+”。另外,您可能想在 xml 中添加样式,例如style="?android:attr/progressBarStyleHorizontal"
根据您的需求。您可能还需要使用android:indeterminateDrawable="@drawable/custom_rating_bar"
而不是 ProgressDrawable
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)