Android開發:通過樣式修改SeekBar背景顏色,進度條顏色,滑塊圖片
阿新 • • 發佈:2018-12-18
通過樣式style修改 seekBar 的 背景、進度、遊標等圖片。
佈局檔案:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--<com.example.zuoxun.CircleProgressBar--> <!--android:layout_width="match_parent"--> <!--android:layout_height="match_parent" />--> <android.support.v7.widget.AppCompatSeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="10dp" android:max="100" android:padding="10dp" android:progress="0" android:progressDrawable="@drawable/seek_img" android:scaleY="0.7" android:thumb="@drawable/cjxq_a" android:thumbOffset="0dp" /> </LinearLayout>
drawable檔案:
<?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:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" /> <solid android:color="#000000" /> <stroke android:width="1dp" android:color="#ffffff" /> </shape> </item> <item android:id="@android:id/progress" android:drawable="@drawable/zx_jiazai_jdt_5km" /> </layer-list>
其他關於seekBar的部落格可檢視參考部落格