展会信息港展会大全

自定义ProgressBar android开发
来源:互联网   发布日期:2015-10-03 10:56:02   浏览:2226次  

导读:1 自定义水平进度条在drawable中新建 horizontal_gridiant_progressbar xml 1 2 3 4 5 6 7 8 910111213?xml version=1 0 encoding=utf-8?layer-list xmlns:android=http: schemas android ...

1.自定义水平进度条

在drawable中新建 horizontal_gridiant_progressbar.xml

1

2

3

4

5

6

7

8

9

10

11

12

13

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:id="@android:id/secondaryProgress">

<clip>

<shape>

<!-- 渐变由白到灰 -->

<gradient

android:endColor="@android:color/darker_gray"

android:startColor="@android:color/white" />

</shape>

</clip>

</item>

</layer-list>

在Layout中设置progressbar

1

2

3

4

5

6

7

<ProgressBar

style="?android:attr/progressBarStyleHorizontal"

android:layout_width="fill_parent"

android:layout_height="50dp"

android:max="100"

android:progress="80"

android:progressDrawable="@drawable/horizontal_gridiant_progressbar" />

2.自定义转动progressbar

在drawable中新建 animated_rotate_progressbar.xml

rotate_progressbar图片

1

2

3

4

5

6

7

8

<?xml version="1.0" encoding="utf-8"?>

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"

android:drawable="@drawable/rotate_progressbar"

android:fromDegrees="0"

android:pivotX="50%"

android:pivotY="50%"

android:toDegrees="360" >

</animated-rotate>

在Layout中设置progressbar

1

2

3

4

5

<ProgressBar

style="?android:attr/progressBarStyleLarge"

android:indeterminateDrawable="@drawable/animated_rotate_progressbar"

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

最终效果图:

赞助本站

人工智能实验室
相关内容
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港