多式样ProgressBar
普通圆形ProgressBar

该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中。

一般只要在XML布局中定义就可以了。

  1. <progressBar android:id="@+id/widget43"
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:layout_gravity="center_vertical">
  5. </ProgressBar>
<progressBar android:id="@+id/widget43"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
</ProgressBar>

此时,没有设置它的风格,那么它就是圆形的,一直会旋转的进度条。

各大小样式圆形ProgressBar
超大号圆形ProgressBar

此时,给设置一个style风格属性后,该ProgressBar就有了一个风格,
这里大号ProgressBar的风格是:

  1. style="?android:attr/progressBarStyleLarge"
 style="?android:attr/progressBarStyleLarge"

完整

XML定义是:

  1. <progressBar android:id="@+id/widget196"
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. style="?android:attr/progressBarStyleLarge">
  5. </ProgressBar>
 <progressBar android:id="@+id/widget196"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge">
</ProgressBar>

小号圆形ProgressBar

小号ProgressBar对应的风格是:

  1. style="?android:attr/progressBarStyleSmall"
 style="?android:attr/progressBarStyleSmall"

完整XML定义是:

  1. <progressBar android:id="@+id/widget108"
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. style="?android:attr/progressBarStyleSmall">
  5. </ProgressBar>
<progressBar android:id="@+id/widget108"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleSmall">
</ProgressBar>

标题型圆形ProgressBar

标题型ProgressBar对应的风格是:

  1. style="?android:attr/progressBarStyleSmallTitle"
style="?android:attr/progressBarStyleSmallTitle"

完整XML定义是:

  1. <progressBar android:id="@+id/widget110"
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. style="?android:attr/progressBarStyleSmallTitle">
  5. </ProgressBar>
<progressBar android:id="@+id/widget110"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleSmallTitle">
</ProgressBar>

代码中实现:

  1. protected void onCreate(Bundle savedInstanceState) {
  2. // TODO Auto-generated method stub
  3. super.onCreate(savedInstanceState);
  4. requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  5. //请求窗口特色风格,这里设置成不明确的进度风格
  6. setContentView(R.layout.second);
  7. setProgressBarIndeterminateVisibility(true);
  8. //设置标题栏中的不明确的进度条是否可以显示
  9. }
protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

        //请求窗口特色风格,这里设置成不明确的进度风格

        setContentView(R.layout.second);

        setProgressBarIndeterminateVisibility(true);

        //设置标题栏中的不明确的进度条是否可以显示

    }

长形进度条

布局中的长形进度条

①首先在XML进行布局

  1. <progressBar android:id="@+id/progressbar_updown"
  2. android:layout_width="200dp"
  3. android:layout_height="wrap_content"
  4. style="?android:attr/progressBarStyleHorizontal"
  5. android:layout_gravity="center_vertical"
  6. android:max="100"
  7. android:progress="50"
  8. android:secondaryProgress="70"    />
<progressBar android:id="@+id/progressbar_updown"

        android:layout_width="200dp" 

        android:layout_height="wrap_content"

        style="?android:attr/progressBarStyleHorizontal"

        android:layout_gravity="center_vertical" 

        android:max="100"

        android:progress="50"

        android:secondaryProgress="70"    /> 

讲解:

  1. style="?android:attr/progressBarStyleHorizontal"
style="?android:attr/progressBarStyleHorizontal" 

设置风格为长形

  1. android:max="100"
android:max="100" 

最大进度值为100

  1. android:progress="50"
android:progress="50"  

初始化的进度值

  1. android:secondaryProgress="70"
android:secondaryProgress="70" 

初始化的底层第二个进度值

  1. android:layout_gravity="center_vertical"
android:layout_gravity="center_vertical"   

垂直居中

②代码中运用

  1. private ProgressBar myProgressBar;
  2. //定义ProgressBar
  3. myProgressBar = (ProgressBar) findViewById(R.id.progressbar_updown);
  4. //ProgressBar通过ID来从XML中获取
  5. myProgressBar.incrementProgressBy(5);
  6. //ProgressBar进度值增加5
  7. myProgressBar.incrementProgressBy(-5);
  8. //ProgressBar进度值减少5
  9. myProgressBar.incrementSecondaryProgressBy(5);
  10. //ProgressBar背后的第二个进度条 进度值增加5
  11. myProgressBar.incrementSecondaryProgressBy(-5);
  12. //ProgressBar背后的第二个进度条 进度值减少5
private ProgressBar myProgressBar;

//定义ProgressBar

myProgressBar = (ProgressBar) findViewById(R.id.progressbar_updown);

//ProgressBar通过ID来从XML中获取

myProgressBar.incrementProgressBy(5);

//ProgressBar进度值增加5

myProgressBar.incrementProgressBy(-5);

//ProgressBar进度值减少5

myProgressBar.incrementSecondaryProgressBy(5);

//ProgressBar背后的第二个进度条 进度值增加5

myProgressBar.incrementSecondaryProgressBy(-5);

//ProgressBar背后的第二个进度条 进度值减少5
 

页面标题中的长形进度条

代码实现:
①先设置一下窗口风格特性

  1. requestWindowFeature(Window.FEATURE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);

//请求一个窗口进度条特性风格

  1. setContentView(R.layout.main);
  2. setProgressBarVisibility(true);
setContentView(R.layout.main);

setProgressBarVisibility(true);

//设置进度条可视

②然后设置进度值

  1. setProgress(myProgressBar.getProgress() * 100);
setProgress(myProgressBar.getProgress() * 100);

//设置标题栏中前景的一个进度条进度值

  1. setSecondaryProgress(myProgressBar.getSecondaryProgress() * 100);
setSecondaryProgress(myProgressBar.getSecondaryProgress() * 100);

//设置标题栏中后面的一个进度条进度值

//ProgressBar.getSecondaryProgress() 是用来获取其他进度条的进度值

ProgressDialog

ProgressDialog中的圆形进度条
     
ProgressDialog一般用来表示一个系统任务或是开启任务时候的进度,有一种稍等的意思。
代码实现:

  1. ProgressDialog mypDialog=new ProgressDialog(this);
  2. //实例化
  3. mypDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  4. //设置进度条风格,风格为圆形,旋转的
  5. mypDialog.setTitle("Google");
  6. //设置ProgressDialog 标题
  7. mypDialog.setMessage(getResources().getString(R.string.second));
  8. //设置ProgressDialog 提示信息
  9. mypDialog.setIcon(R.drawable.android);
  10. //设置ProgressDialog 标题图标
  11. mypDialog.setButton("Google",this);
  12. //设置ProgressDialog 的一个Button
  13. mypDialog.setIndeterminate(false);
  14. //设置ProgressDialog 的进度条是否不明确
  15. mypDialog.setCancelable(true);
  16. //设置ProgressDialog 是否可以按退回按键取消
  17. mypDialog.show();
  18. //让ProgressDialog显示
 ProgressDialog mypDialog=new ProgressDialog(this);

            //实例化

            mypDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

            //设置进度条风格,风格为圆形,旋转的

            mypDialog.setTitle("Google");

            //设置ProgressDialog 标题

            mypDialog.setMessage(getResources().getString(R.string.second));

            //设置ProgressDialog 提示信息

            mypDialog.setIcon(R.drawable.android);

            //设置ProgressDialog 标题图标

            mypDialog.setButton("Google",this);

            //设置ProgressDialog 的一个Button

            mypDialog.setIndeterminate(false);

            //设置ProgressDialog 的进度条是否不明确

            mypDialog.setCancelable(true);

            //设置ProgressDialog 是否可以按退回按键取消

            mypDialog.show();

            //让ProgressDialog显示

ProgressDialog中的长形进度条
     
代码实现:

  1. ProgressDialog mypDialog=new ProgressDialog(this);
  2. //实例化
  3. mypDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  4. //设置进度条风格,风格为长形,有刻度的
  5. mypDialog.setTitle("地狱怒兽");
  6. //设置ProgressDialog 标题
  7. mypDialog.setMessage(getResources().getString(R.string.second));
  8. //设置ProgressDialog 提示信息
  9. mypDialog.setIcon(R.drawable.android);
  10. //设置ProgressDialog 标题图标
  11. mypDialog.setProgress(59);
  12. //设置ProgressDialog 进度条进度
  13. mypDialog.setButton("地狱曙光",this);
  14. //设置ProgressDialog 的一个Button
  15. mypDialog.setIndeterminate(false);
  16. //设置ProgressDialog 的进度条是否不明确
  17. mypDialog.setCancelable(true);
  18. //设置ProgressDialog 是否可以按退回按键取消
  19. mypDialog.show();
  20. //让ProgressDialog显示
  21. AlertDialog.Builder
  22. AlertDialog中的圆形ProgressBar

ProgressBar 各种样式的更多相关文章

  1. WPF 自定义ProgressBar滚动条样式

    一.前言 滚动条一般用于加载进度,我们在看视频的时候或者在浏览网页的时候经常能看到加载进度的页面.在程序开发中,默认的进度加载样式可能跟程序风格不太一样,或者加载进度的时候需要更改一下加载的样式.这个 ...

  2. 分享个新浪下载图片的ProgressBar进度样式

    https://github.com/eltld/ImageLoadProgress2

  3. Android 常用控件自定义样式RadioButton、CheckBox、ProgressBar、

    一.RadioButton / CheckBox 系统自带的RadioButton/CheckBox的样式,注定满足不了实际运用中的情况,有时候自定义自己的样式:此次把自己中工作学习过程中所学到的东西 ...

  4. Android中自定义ProgressBar

    <ProgressBar             android:id="@+id/more_vprogress_more"             android:layo ...

  5. Android简单自定义圆形和水平ProgressBar

    ProgressBar简介 继承于View类,直接子类有AbsSeekBar和ContentLoadingProgressBar,其中AbsSeekBar的子类有SeekBar和RatingBar,可 ...

  6. 【读书笔记《Android游戏编程之从零开始》】5.Android 游戏开发常用的系统控件(ProgressBar、Seekbar)

    3.7 ProgressBar ProgressBar类官方文档地址:http://developer.android.com/reference/android/widget/ProgressBar ...

  7. 写一个自己定义进度颜色和圆形转动的ProgressBar(具体介绍)

    先上图: 我们得自己定义ProgressBar的样式 <span style="white-space:pre"> </span><style nam ...

  8. 关于ProgressBar的美化问题

    Android自带的ProgressBar其实也算不上丑陋,但是如果所有的App都使用一个模式的ProgressBar,那么估计用户就要崩溃了,打开任何一个App,擦,进度条都一模一样..有鉴于此,我 ...

  9. ProgressBar 基本介绍

    简介 ProgressBar 继承自View,用于在界面上显示一个进度指示的界面. 1.ProgressBar有两个进度,一个是android:progress,另一个是android:seconda ...

随机推荐

  1. 使用Subversion进行版本控制

    使用Subversion进行版本控制 针对 Subversion 1.4(根据r2866编译) Ben Collins-Sussman Brian W. Fitzpatrick C. Michael  ...

  2. 关于解压覆盖IIS文件后,新的文件不具备权限导致DMS系统无法正常运行

     向DMS的服务器端站点bin目录覆盖任何补丁文件,请注意:Web站点的bin目录中的文件,IIS的服务进程(Windows2003以上,都是对应Network Services账户)必须对这些文件具 ...

  3. (3)VS2010+Opencv-2.4.8的配置攻略

    这是windows平台上的东西,我为什么要写到安卓这一块呢 因为作者做的安卓方面的东西需要先在windows平台实现一下,所以就想写这篇东西,也参考了网上很多教程,不得不感叹,这些软件版本更新的太快. ...

  4. appium自动化测试中获取toast消息的解决方法【转】

    http://blog.csdn.net/hqzxsc2006/article/details/50036911 待实践.. 解决方法:appium下切换selendroid模式去获取Android的 ...

  5. 矩阵快速幂 POJ 3735 Training little cats

    题目传送门 /* 题意:k次操作,g:i猫+1, e:i猫eat,s:swap 矩阵快速幂:写个转置矩阵,将k次操作写在第0行,定义A = {1,0, 0, 0...}除了第一个外其他是猫的初始值 自 ...

  6. Hadoop基础教程之高级编程

    从前面的学习中,我们了解到了MapReduce整个过程需要经过以下几个步骤: 1.输入(input):将输入数据分成一个个split,并将split进一步拆成<key, value>. 2 ...

  7. 移动设备中导入gdb调试工具

    (1)概述 接ADB调试桥安装(方式一),ADB调试桥安装好了后一般的移动设备内都不含有gdb工具, 要想使用gdb工具可以借助adb的push参数进行上传. gdb分为gdb客户端和服务端,文件可以 ...

  8. Regex 字符是不是汉字

    Regex   字符是不是汉字 一. 判断一个字符是不是汉字通常有三种方法: 1.用ASCII码判断 在 ASCII码表中,英文的范围是0-127,而汉字则是大于127 string text = & ...

  9. (三)在js(jquery)中获得文本框焦点和失去焦点的方法

    在js(jquery)中获得文本框焦点和失去焦点的方法   文章介绍两个方法和种是利用javascript onFocus onBlur来判断焦点和失去焦点,加一种是利用jquery $(" ...

  10. 详细记录python的range()函数用法

    使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节.这里记录一下range(),复习下list的slide,最后分析一个好玩儿的冒泡程序. 这里记 ...