Android自定義進(jìn)度條樣式
來源:程序員人生 發(fā)布時(shí)間:2015-01-08 13:47:24 閱讀次數(shù):4888次
最近在做1個(gè)widget,上面需要1個(gè)progressbar,產(chǎn)品經(jīng)理和設(shè)計(jì)師給出來的東西是要實(shí)現(xiàn)1個(gè)圓角的progress和自定義的色彩,研究1小下,分享出來給大家哦。

測試于:Android4.0+
操作步驟:
1.創(chuàng)建你的layout文件援用progressbar以下,標(biāo)紅處援用你自定的樣式;
<ProgressBar
android:id="@+id/progressDownload"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="22dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/progress_horizontal_widgt" />
2.在你的res下的drawable中創(chuàng)建progress_horizontal_widgt.xml 名字你自己可以隨意起
<?xml version="1.0" encoding="utf⑻"?>
<!-- Copyright (C) 2008 The Android Open Source Project Licensed under the
Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE⑵.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="11dp" />
<solid android:color="#8842323f" />
<stroke android:width="1px" android:color="#884d363a" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="11dp" />
<solid android:color="#5aade3" />
<stroke android:width="1px" android:color="#884d363a" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="11dp" />
<solid android:color="#5aade3" />
<stroke android:width="1px" android:color="#884d363a" />
</shape>
</clip>
</item>
</layer-list>
效果截圖:(色彩有出入,可以自行調(diào)劑)

轉(zhuǎn)載請(qǐng)注明:破曉博客 ? [原創(chuàng)]Android自定義進(jìn)度條樣式
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)