我必须为 Android 创建 SeekBar 样式,但不知道如何做到这一点。这是最终结果的图片(我想要达到的效果)。
我们先从SeekBar的背景开始吧。我尝试将其分成三个部分:左圆端、中间部分的可重复部分和右圆端。它们应该与下一个代码(foo_background.xml)连接。
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="horizontal" >
<bitmap
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left|center_vertical"
android:src="@drawable/foo_left"
android:tileMode="disabled" />
<bitmap
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="center_vertical"
android:src="@drawable/foo_middle"
android:tileMode="repeat" />
<bitmap
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="right|center_vertical"
android:src="@drawable/foo_right"
android:tileMode="disabled" />
</clip>
它在SeekBar的背景可绘制文件中使用。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<clip android:drawable="@drawable/foo_background" />
</item>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/seek_bar_progress" />
</item>
</layer-list>
但是由于所有这些东西,我看到一个空的(或者更好地说我没有看到它)SeekBar 进度线。
有人知道如何以正确的方式做到这一点吗? 非常感谢您的帮助。
最佳答案
尝试下面的链接,您将获得一些有关搜索栏自定义的信息。
http://www.techrepublic.com/blog/app-builder/androids-seekbar-your-way/943
或者
http://developer-dot-android.blogspot.in/2012/03/custom-seekbar-tutorial.html
这可能对你有帮助......
关于Android SeekBar 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12512349/