Android自定义进度条样式

最近在做一个widget,上面需要一个progressbar,产品经理和设计师给出来的东西是要实现一个圆角的progress和自定义的颜色,研究一小下,分享出来给大家哦。

测试于:Android4.0+

操作步骤:

1.创建你的layout文件引用progressbar如下,标红处引用你自定的样式;

<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中创建progress_horizontal_widgt.xml 名字你自己可以随便起

<?xml version="1.0" encoding="utf-8"?>
<!-- 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-2.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>

效果截图:(颜色有出入,可以自行调整)

转载请注明:破晓博客 ? [原创]Android自定义进度条样式

时间: 2024-08-01 10:44:19

Android自定义进度条样式的相关文章

最简单的android自定义进度条样式

一.自定义圆形进度条样式 1.在安卓项目drawable目录下新建一个xml文件如下:<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:pivotX="50%" android:pivotY="50%" andro

android 自定义进度条颜色

先看图 基于产品经理各种自定义需求,经过查阅了解,下面是自己对Android自定义进度条的学习过程!   这个没法了只能看源码了,还好下载了源码, sources\base\core\res\res\  下应有尽有,修改进度条颜色只能找progress ,因为是改变样式,首先找styles.xml 找到xml后,进去找到 [html] view plaincopyprint? <span style="font-size: 18px;">    <style name

Android自定义进度条-带文本(文字进度)的水平进度条(ProgressBar)

/** * 带文本提示的进度条 */ public class TextProgressBar extends ProgressBar { private String text; private Paint mPaint; public TextProgressBar(Context context) { super(context); initText(); } public TextProgressBar(Context context, AttributeSet attrs, int d

Android 自定义进度条,

最近工作繁忙,一直都埋头在工作中,也不知这么热心工作究竟是为了什么,不知不觉的,到今天才晓得夏天已经来了.天气热,心也热. 网络上出个牛人,辞职信上写着:世界那么大,我想去看看.由衷的佩服她的勇气,我也想去看看这大千世界,可惜我们总是身不由己,有太多的放不下,或许哪天放下了,我也出去走走. 之前一直以为罗永浩是个逗比,直到前两天看了他几期演讲,才发现逗比一直是我.他有句话我很欣赏,这里也分享给大家:在什么样的年纪,就做什么样的事情,怎么能在每个阶段都做错呢!PS:该玩的年纪玩,该谈恋爱的年纪谈恋

自定义进度条\文字描边样式\文字上下滚动TextSwithcher的应用

一.自定义进度条 1.<ProgressBar         android:id="@+id/patch_progress"         style="@style/gxProgressStyle"         android:layout_width="match_parent"         android:layout_height="12dp"         android:layout_alig

自定义水平进度条样式:黑色虚线

布局layout中使用: 1 <ProgressBar 2 android:id="@+id/progress_bar" 3 style="?android:attr/progressBarStyleHorizontal" <!--必须设置为水平--> 4 android:progressDrawable="@drawable/myprogress" <!--此处用自定义样式--> 5 android:layout_

[Android]组件-进度条1

多式样ProgressBar 普通圆形ProgressBar 该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中. 一般只要在XML布局中定义就可以了. <progressBar android:id="@+id/widget43" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layou

Android中进度条类型的控件定义和妙用技巧

Android中进度条控件有3个(不算ProgressDialog),分别是ProgressBar,SeekBar和RatingBar,对于自定义样式来说又得按照需求分为2中情况,第一种是刻度型,第二种是循环类型. 第一种是"刻度型",也就是他有起点和终点,起点值小于终点值 这种样式的修改,要修改三个属性即可 分别是:背景(主要是进度的轨道样式),第一级别滚动条progressDrawable,第二级别progressDrawable 遗憾的是Android提供的api很难设置,不过可

自定义进度条PictureProgressBar——从开发到开源发布全过程

自定义进度条PictureProgressBar--从开发到开源发布全过程 出处: 炎之铠邮箱:[email protected] 本文原创,转载请注明本出处! 本项目JCenter地址:https://bintray.com/yanzhikaijky/CustomViewRepository/PictureProgressbar/ 本项目GitHub地址:https://github.com/totond/PictureProgressBar 欢迎 Star or Fork和在Issue里提出