【发布时间】:2013-08-30 05:43:48
【问题描述】:
我打算制作一个自定义搜索栏,用我自己的一组图像作为背景和进度可绘制对象。我制作了 2 个 9-patch 图像,每个用于背景和进度可绘制对象。这是我用于progressDrawable的代码:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/background"
android:drawable="@drawable/experience_seekbar_background" />
<item android:id="@+id/progress">
<clip
android:clipOrientation="horizontal"
android:gravity="left|top"
android:drawable="@drawable/experience_seekbar_progress" />
</item>
</layer-list>
另外,这里是我的搜索栏的 xml 定义:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp" >
<SeekBar
android:id="@+id/experienceSeekBar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:max="2"
android:progress="1"
android:progressDrawable="@drawable/experience_seekbar" />
</LinearLayout>
问题是,drawable的进度部分绘制在背景部分下方,而不是直接重叠。
预期/期望:(http://i.imgur.com/C27dQZK.png)
实际输出:(http://i.imgur.com/ftNlMMI.png)
阅读了数十个自定义搜索栏教程后,我仍然不知道我在这里可能做错了什么。这可能是非常微不足道的事情,但我无法发现它。
【问题讨论】:
标签: android custom-controls drawable seekbar