转载自: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. Window.document对象(1)

    1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个:     var a =docunme ...

  2. 【递推】BZOJ 4300:绝世好题

    4300: 绝世好题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 564  Solved: 289[Submit][Status][Discuss] ...

  3. 【BZOJ】【1449】【JSOI2009】球队收益

    网络流/费用流/二分图最小权匹配 题解:http://blog.csdn.net/huzecong/article/details/9119741 太神了!由于一赢一输不好建图,就先假设全部都输,再将 ...

  4. JavaScript 性能分析新工具 OneProfile

    OneProfile 是一个网页版的小工具,可以用全新的方式展示 JavaScript 性能分析的结果,帮助开发者洞悉函数调用关系,优化应用性能. 点击打开 OneProfile 背景 Chrome ...

  5. HDU 4632 Palindrome subsequence(区间dp,回文串,字符处理)

    题目 参考自博客:http://blog.csdn.net/u011498819/article/details/38356675 题意:查找这样的子回文字符串(未必连续,但是有从左向右的顺序)个数. ...

  6. POJ 1995

    #include <iostream> using namespace std; long long power(long long a, long long b, long long m ...

  7. Android 源码 判断网络数据类型

    private final void updateDataNetType(int slotId) { int tempDataNetType; NetworkType tempDataNetType3 ...

  8. Shell实现跳板机,为什么用跳板机

    整理自:http://blog.chinaunix.net/uid-22101889-id-3167454.html 注意:请谨慎使用,到现在为止,使用了,我还没找到改回去的方法. 1.     问题 ...

  9. Java框架----SSH整合回顾

    1,新建工程,类型为Web Project,设置默认编码为UTF-8,并创建如下文件夹 1,Source Folder 1,src 项目源码 2,config 配置文件 3,test 单元测试 2,普 ...

  10. 深入了解linux下的last命令及其数据源

    http://www.9usb.net/200902/linux-last.html http://blog.csdn.net/chaofanwei/article/details/11826567