实习入职第十六天:seekBar自定义样式

progressDrawable的定义:


<?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>
            <corners android:radius="5dip" />
            <gradient
                    android:startColor="#ff364956"
                    android:centerColor="#ff444444"
                    android:centerY="0.75"
                    android:endColor="#ff00112e"
                    android:angle="90"
            />
        </shape>
    </item>
    
    <item android:id="@android:id/secondaryProgress">
       <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                        android:startColor="#80364956"
                        android:centerColor="#802f67a6"
                        android:centerY="0.75"
                        android:endColor="#8000112e"
                        android:angle="270"
                />
            </shape>
        </clip>
    </item>
    
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                        android:startColor="#ff9ee5ff"
                        android:centerColor="#ff9ee5ff"
                        android:centerY="0.75"
                        android:endColor="#ff9ee5ff"
                        android:angle="90"
                />
            </shape>
        </clip>
    </item>
    

</layer-list>


thumb定义:

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


    <solid android:color="#ffec700c" />


    <size
        android:height="8.0dip"
        android:width="8.0dip" />


</shape>

style的定义:

    <style name="MediaController_SeekBar">
        <item name="android:maxHeight">16.0dip</item>
        <item name="android:progressDrawable">@drawable/mediacontroller_seekbar_drawable</item>
        <item name="android:minHeight">16.0dip</item>
        <item name="android:thumb">@drawable/mediacontroller_seekbar_thumb</item>
    </style>


布局里面的使用:

    <SeekBar
        android:id="@+id/seekbar"
        android:layout_width="0dp"
        style="@style/MediaController_SeekBar"
        android:layout_height="wrap_content"
        android:layout_marginEnd="5dp"
        android:layout_weight="5.0"
        android:max="100"
        android:maxHeight="5dp"
        android:minHeight="5dp"
        android:progress="0"
        android:thumbOffset="0dp" />

你可能感兴趣的:(实习入职第十六天:seekBar自定义样式)