自定义SeekBar布局错误?

时间:2011-10-14 09:58:54

标签: android seekbar

我从 this 创建了自定义搜索栏布局,现在我在xml文件中收到这样的错误

Failed to parse file C:\Documents and Settings\jkreddy\Desktop\RAJA\programs\
Light\res\drawable\seekbar_progress.xml 

这是xml代码

<SeekBar            
    android:id="@+id/frequency_slider"
    android:layout_marginLeft="10px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:max="9"
    android:progress="0"
    android:secondaryProgress="0"
    android:progressDrawable="@drawable/seekbar_progress"
    android:thumb="@drawable/seek_thumb"/>

seekbar_progress_bg的代码

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <clip>
        <shape>
            <gradient
                android:startColor="#FF5e8ea3"
                android:centerColor="#FF32a0d2"
                android:centerY="0.1"
                android:endColor="#FF13729e"
                android:angle="270"/>
        </shape>
    </clip>
</item>
<item>
    <clip>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/colorbar"
        android:tileMode="repeat"
        android:antialias="true"
        android:dither="false"
        android:filter="false"
        android:gravity="left"/>
    </clip>
</item>

seekbar_progress的代码

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
    <nine-patch
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/colorbar_e"
        android:dither="true"/>
</item>
<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape>
            <gradient
                android:startColor="#80028ac8"
                android:centerColor="#80127fb1"
                android:centerY="0.75"
                android:endColor="#a004638f"
                android:angle="270"/>
        </shape>
    </clip>
</item>
<item
    android:id="@android:id/progress"
    android:drawable="@drawable/seekbar_progress_bg"/>

1 个答案:

答案 0 :(得分:2)

这是另一种用于创建自定义SeekBar

的表单
<SeekBar                    
    android:id="@+id/frequency_slider"
    android:layout_marginLeft="15px"
    android:layout_width="200px"
    android:layout_height="wrap_content" 
    android:max="9"
    android:thumbOffset="0px"
    android:progress="0"                 
    android:progressDrawable="@drawable/progress"
    android:thumb="@drawable/thumb"/>

progress.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" 
       android:drawable="@drawable/slider" />

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

thumb.xml

<?xml version="1.0" encoding="utf-8"?>    
  <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/seek_thumb" />
</selector>