【发布时间】:2016-09-14 10:57:42
【问题描述】:
如何为包含位图的 SeekBar 的进度状态添加圆角?
这个进度位图是一个PNG文件,其中包含一个要重复的模式,这就是为什么我不能为这个状态使用九个补丁。
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<nine-patch android:src="@drawable/background"/>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<nine-patch android:src="@drawable/secondary_progress"/>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<bitmap android:src="@drawable/progress" android:tileMode="repeat"/>
</clip>
</item>
</layer-list>
想要的外观:
【问题讨论】:
-
发布一张想要的图片
-
我添加了图片
-
而不是
<bitmap android:src="@drawable/progress" android:tileMode="repeat"/>使用“圆形矩形”ShapeDrawable并设置它的ShapeDrawable.ShaderFactory以便它返回BitmapShader,我知道这不是简单的解决方案,但我担心唯一简单的解决方案是自定义Drawable类,例如 this -
谢谢@pskink,我去看看。
-
here 你有如何在 xml 和 java 代码中做到这一点(你可以删除
sd.getPaint().setColor(Color.RED);行,因为它用于测试)
标签: android android-bitmap android-seekbar