Android SeekBar 样式自定义

Android下修改SeekBar样式
SeekBar配置文件:
<pre name="code" class="html"><SeekBar
    android:id="@+id/player_seekbar"
    android:layout_width="245px"
    android:layout_height="25px"
    android:max="0"
    android:paddingBottom="5px"
    android:paddingLeft="16px"
    android:paddingRight="15px"
    android:paddingTop="5px"
    android:progress="0"
    android:progressDrawable="@drawable/seekbar_style"
    android:secondaryProgress="0"
    android:thumb="@drawable/thumb" />

android:progressDrawable="@drawable/seekbar_style"背景条

seekbar_style配置如下:

<?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:angle="270"
                android:centerColor="#ff5a5d5a"
                android:centerY="0.75"
                android:endColor="#ff747674"
                android:startColor="#ff9d9e9d" />
        </shape>
    </item>
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />

                <gradient
                    android:angle="270"
                    android:centerColor="#80ffb600"
                    android:centerY="0.75"
                    android:endColor="#a0ffcb00"
                    android:startColor="#80ffd300" />
            </shape>
        </clip>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="5dip" />

                <gradient
                    android:angle="270"
                    android:centerColor="#ff3399CC"
                    android:centerY="0.75"
                    android:endColor="#ff6699CC"
                    android:startColor="#ff0099CC" />
            </shape>
        </clip>
    </item>

</layer-list>

 或者:用图片如下:
 
<span style="font-family: Tahoma; font-size: 14px; line-height: 24px;"></span><pre name="code" class="html"><?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/progress_bg"/>
    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/second_progress">
    </item>
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/first_progress">
    </item>

</layer-list>

 方形
 
<span style="font-family: Tahoma; font-size: 14px; line-height: 24px;"><span style="font-family: Tahoma; font-size: 14px; line-height: 24px;"></span></span><pre name="code" class="html"><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@android:id/background"
        android:drawable="@drawable/progress_bg"/>
    <item android:id="@android:id/secondaryProgress">
        <clip android:drawable="@drawable/second_progress" />
    </item>
    <item android:id="@android:id/progress">
        <clip android:drawable="@drawable/first_progress" />
    </item>

</layer-list>
android:thumb="@drawable/thumb"就是那个会动的球 
配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">     
	
    <!-- 按下状态-->
	<item 
		android:state_focused="true" 
		android:state_pressed="true" 
		android:drawable="@drawable/thumb_pressed" />     
	<!-- 普通无焦点状态 -->
	<item 
		android:state_focused="false" 
		android:state_pressed="false"
		android:drawable="@drawable/thumb_normal" />           
	<!-- 有焦点状态-->
	<item 
		android:state_focused="true" 
		android:state_pressed="false"           
		android:drawable="@drawable/thumb_focused" />      
	<!-- 有焦点 -->
	<item 
		android:state_focused="true"           
		android:drawable="@drawable/thumb_focused" />  
</selector>

转自:http://www.myexception.cn/android/651126.html
 

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值