Android SeekBar 自定义

标签 android

我必须为 Android 创建 SeekBar 样式,但不知道如何做到这一点。这是最终结果的图片(我想要达到的效果)。

enter image description here

我们先从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/

相关文章:

android - AppBarLayout 内的 BottomNavigationView

android - 为移动设备创建链接的正确方法是什么?

java.lang.OutOfMemoryError 在 android 中加密大文件

android - 如何使用自定义 key 编写 MifareClassic

android - Realm createAllFromJson 抛出 BEGIN_ARRAY 但 BEGIN_OBJECT 异常

java - 双击 : zoom on Android MapView?

在选项卡更改时调用 Android fragment oncreateview

php - 如何将通知从php服务器发送到android应用程序

JavaScript 不适用于 android WebView,Uncaught ReferenceError

java - Android 自动完成 TextView 建议下拉菜单出现在软键盘下方