转载自:eoe社区,可惜没找到源地址。。。


多式样ProgressBar

普通圆形ProgressBar

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

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

    <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的风格是:

style="?android:attr/progressBarStyleLarge"

完整XML定义是:

    <progressBar android:id="@+id/widget196"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge">
</ProgressBar>

小号圆形ProgressBar

小号ProgressBar对应的风格是:

style="?android:attr/progressBarStyleSmall"

完整XML定义是:

    <progressBar android:id="@+id/widget108"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleSmall">
</ProgressBar>

标题型圆形ProgressBar

标题型ProgressBar对应的风格是:

style="?android:attr/progressBarStyleSmallTitle"

完整XML定义是:

    <progressBar android:id="@+id/widget110"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleSmallTitle">
</ProgressBar>

代码中实现:

    @Override
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进行布局

    <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" >

讲解:

style="?android:attr/progressBarStyleHorizontal"    设置风格为长形 
android:max="100"    最大进度值为100
android:progress="50"   初始化的进度值
android:secondaryProgress="70"  初始化的底层第二个进度值 
android:layout_gravity="center_vertical"    垂直居中

②代码中运用

    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

页面标题中的长形进度条

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

    requestWindowFeature(Window.FEATURE_PROGRESS);
//请求一个窗口进度条特性风格
setContentView(R.layout.main);
setProgressBarVisibility(true);
//设置进度条可视

②然后设置进度值

    setProgress(myProgressBar.getProgress() * 100);
//设置标题栏中前景的一个进度条进度值
setSecondaryProgress(myProgressBar.getSecondaryProgress() * 100);
//设置标题栏中后面的一个进度条进度值
//ProgressBar.getSecondaryProgress() 是用来获取其他进度条的进度值

ProgressDialog

ProgressDialog中的圆形进度条
      
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中的长形进度条

      



 

代码实现:

    ProgressDialog mypDialog=new ProgressDialog(this);
//实例化
mypDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
//设置进度条风格,风格为长形,有刻度的
mypDialog.setTitle("地狱怒兽");
//设置ProgressDialog 标题
mypDialog.setMessage(getResources().getString(R.string.second));
//设置ProgressDialog 提示信息
mypDialog.setIcon(R.drawable.android);
//设置ProgressDialog 标题图标
mypDialog.setProgress(59);
//设置ProgressDialog 进度条进度
mypDialog.setButton("地狱曙光",this);
//设置ProgressDialog 的一个Button
mypDialog.setIndeterminate(false);
//设置ProgressDialog 的进度条是否不明确
mypDialog.setCancelable(true);
//设置ProgressDialog 是否可以按退回按键取消
mypDialog.show();
//让ProgressDialog显示

AlertDialog.Builder

AlertDialog中的圆形ProgressBar


 

①先来设计一个Layout,待会儿作为一个View,加入AlertDialog.Builder

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</LinearLayout>
<ProgressBar android:layout_gravity="center_vertical|center_horizontal"
android:layout_height="wrap_content"
android:progress="57"
android:id="@+id/myView_ProgressBar2"
android:layout_width="wrap_content">
</ProgressBar>
</LinearLayout>

②代码罗

    private AlertDialog.Builder AlterD,AlterD2;
//定义提示对话框
private LayoutInflater layoutInflater;
//定义布局过滤器
private LinearLayout myLayout;
//定义布局
layoutInflater2=(LayoutInflater) getSystemService(this.LAYOUT_INFLATER_SERVICE);
//获得系统的布局过滤服务
myLayout2=(LinearLayout) layoutInflater2.inflate(R.layout.roundprogress, null);
//得到事先设计好的布局
AlterD2.setTitle(getResources().getString(R.string.RoundO));
//设置对话框标题
AlterD2.setIcon(R.drawable.ma);
//设置对话框图标
AlterD2.setMessage(getResources().getString(R.string.ADDView));
//设置对话框提示信息
AlterD2.setView(myLayout2);
//设置对话框中的View
AlterD2.show();
//让对话框显示

AlertDialog中的长形ProgressBar(可控制)
 
①先来设计一个Layout,待会儿作为一个View,加入AlertDialog.Builder

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_height="wra

android ProgressBar 样式讲解的更多相关文章

  1. 改变Android ProgressBar样式颜色

    地址: http://blog.csdn.net/lvxiangan/article/details/9110121

  2. Android ProgressBar的使用

    Android 基础教程之-------Android ProgressBar的使用http://blog.csdn.net/Android_Tutor/article/details/5695170 ...

  3. android自定义样式大全:shape,selector,layer-list,style,动画全部内容

    原文:http://keeganlee.me/post/android/20150830 以下摘取了部分内容: shape 一般用shape定义的xml文件存放在drawable目录下,若项目没有该目 ...

  4. android studio样式文件汇总

    android studio样式文件汇总:shape.Theme|styles .selector 1:shape shape用于设定形状,有6个子标签,各属性如下: res/drawable/sty ...

  5. Android spinner 样式及其使用详解

    设计与开发首页 > 应用专题 > 移动开发 > 正文> Android spinner 样式及其使用详解 相关文章: Android 开源项目应用程序与框架推荐 Android ...

  6. 这些Android系统样式中的颜色属性你知道吗?

    Android 系统样式中的颜色属性 推荐阅读看完后彻底搞清楚Android中的 Attr . Style .Theme 几个常用的颜色属性 先放上一张经典的图片,图片来自网络. 这张图在网上很是流传 ...

  7. Android自定义ProgressBar样式

    我们使用的进度条多种多样,下面有几种自定义的进度条的样式,下面介绍几个. 进度条的有基本的四种样式: 默认风格的进度条: android:progressBarStyle 水平长型进度条: andro ...

  8. android 自定义progressbar 样式

    在res下创建drawable文件夹,新建文件drawable/progressbar_color.xml <layer-list xmlns:android="http://sche ...

  9. Android用户界面 UI组件--TextView及其子类(三) EditView以及各种Span文字样式讲解

    EditView和TextView的用法差不多,只是文字可编辑 小技巧: 设置EditText隐藏键盘  setInputType(0); 设置EditText不被输入法遮盖  getWindow() ...

随机推荐

  1. 百度地图之POI

    // // PoiViewController.m // baiDuDemo // // Created by City--Online on 15/6/4. // Copyright (c) 201 ...

  2. udp 视频包网络传输花屏

    视频数据传输在传输层可以选择TCP或者UDP,TCP面向连接,传输中断,发送端是知道的.TCP传输的好处是不丢包,坏处是网络不太好的情况下会越堵越严重.UDP非面向连接,发送端只管发送数据,接收端有没 ...

  3. HTML5 编码规范

    在编写HTML时,可能有一些方面不够规范,在通过对<HTML5编码规范>的学习后,采用代码注解的方式,做相关的整理,方便今后回顾. <!DOCTYPE html> <!- ...

  4. [译] TypeScript入门指南(JavaScript的超集)

    你是否听过 TypeScript? TypeScript 是 JavaScript 的超集,TypeScript结合了类型检查和静态分析,显式接口.TypeScript是微软的开源项目,它是由C#之父 ...

  5. 设计模式之适配器模式(Adapter)

    适配器模式原理:适配器模式属于结构型模式,主要作用是完成功能的转换, 1.通过一个类继承目标类. 2.需要适配的类 3.适配器 代码如下: #include <iostream> usin ...

  6. MAC下搭建web开发环境

    具体做法,参照此链接:http://mallinson.ca/osx-web-development/ Mac系统本身自带apache和PHP,MySQL可以安装也可以不安装 web开发的IDE可以是 ...

  7. UML 2.0(装载)

    在世界上统一建模语言UML2.0是完全不同的维度.它在本质上更加复杂和广泛. 与UML1.5版本相比,文件的程度也增加了. UML2.0中还增加了新的功能,所以它的使用可以更广泛. UML2.0将正式 ...

  8. Sqli-labs less 18

    Less-18 本关我们这里从源代码直接了解到 对uname和passwd进行了check_input()函数的处理,所以我们在输入uname和passwd上进行注入是不行的,但是在代码中,我们看到了 ...

  9. 【译】使用 Python 编写虚拟机解释器

    [译]如何使用 Python 创建一个虚拟机解释器? 原文地址:Making a simple VM interpreter in Python 更新:根据大家的评论我对代码做了轻微的改动.感谢 ro ...

  10. Eclipse 字体选择

    Windows下推荐使用Consolas Linux下推荐使用DejaVu Sans Mono, Website: http://dejavu-fonts.org/wiki/Main_PageDown ...