您好,登錄后才能下訂單哦!
系統(tǒng)默認(rèn)的seekbar很多時候不符合開發(fā)需求,那么就需要自定義seekbar的樣式,方法并不復(fù)雜,下面記錄一下:
布局文件中:
android:thumb="@drawable/sanjiaoup"
通過這樣一行代碼就可以更換滑動圖標(biāo),圖片自己選擇合適的就行。
自定義進(jìn)度條布局文件中加入這個:
android:progressDrawable="@drawable/seekbar_style"
自定義drawable中加入layer-list
<?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="1000dip" /> <!-- startColor表示開始顏色,endColor表示結(jié)束顏色,centerColor表示中心顏色,3者結(jié)合成進(jìn)度條顏色效果 --> <!-- centerY表示進(jìn)度條的粗細(xì),越小的話越粗,越大則越細(xì) --> <gradient android:angle="270" android:centerColor="#005a5d5a" android:centerY="0.75" android:endColor="#000000" android:startColor="#00ffffff" /> </shape> </item> <item android:id="@android:id/secondaryProgress"> <clip> <shape> <corners android:radius="5dip" /> <gradient android:angle="270" android:centerColor="#00ffb600" android:centerY="0.75" android:endColor="#00ffcb00" android:startColor="#00ffd300" /> </shape> </clip> </item> 這里是滑動過后的樣式 <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="100dip" /> <gradient android:angle="270" android:centerColor="#fc0000" android:centerY="0.75" android:endColor="#fc0000" android:startColor="#fc0000" /> </shape> </clip> </item> </layer-list>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。