1

我正在使用以下搜索栏

<SeekBar
    android:id="@+id/sbCardSpeed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_marginRight="5dp"
    android:max="100"
    android:progress="50"
    android:progressDrawable="@drawable/seekbar_progress"/>

seekbar_progress.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background"
        android:drawable="@drawable/background_fill"
    />

    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/seekbar_progress_bg"
    />
</layer-list>

background_fill.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
        android:startColor="#FFFFFF" //white color
        android:centerColor="#FFFFFF"
        android:endColor="#FFFFFF"
        android:angle="90" />

</shape>

seekbar_progress_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
        android:startColor="#FF8400"  //orange color
        android:centerColor="#FF8400"
        android:endColor="#FF8400"
        android:angle="90" />

</shape>

进度条是橙色的一种颜色的问题。如果我移动拇指,它的两边仍然是橙色的。白色背景未显示。我做错了什么?

谢谢 在此处输入图像描述

4

1 回答 1

2

尝试这个....

seekbar_progress.xml:

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:maxLevel="10000" android:drawable="@drawable/progress_horizontal_orange" />
</level-list>

progress_horizo​​ntal_orange.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@android:id/background">
    <shape>
           <gradient
                android:startColor="#ffffff"
                android:endColor="#ffffff"/>
    </shape>
</item>

<item android:id="@android:id/progress">
    <clip>
        <shape>
            <gradient
                 android:startColor="#FF8400"
                 android:endColor="#FF8400"
                 android:angle="90"
            />
        </shape>
    </clip>
</item>

</layer-list>
于 2013-05-23T05:43:56.013 回答