背景と進行状況のドローアブル用に独自の画像セットを使用して、カスタム シークバーを作成するつもりです。背景とプログレス ドローアブル用に 1 つずつ、2 つの 9 パッチ イメージを作成しました。これが私が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 )
何十回ものカスタム シークバー チュートリアルを行ってきましたが、ここで間違っている可能性があることにまだ行き詰まっています。それは非常に些細なことかもしれませんが、私はそれを見つけることができません。