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 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"
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 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"
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 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"
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>
<progressBar android:id="@+id/widget110"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleSmallTitle">
</ProgressBar>
代码中实现:
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
- //请求窗口特色风格,这里设置成不明确的进度风格
- setContentView(R.layout.second);
- setProgressBarIndeterminateVisibility(true);
- //设置标题栏中的不明确的进度条是否可以显示
- }
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" />
<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"
style="?android:attr/progressBarStyleHorizontal"
设置风格为长形
- android:max="100"
android:max="100"
最大进度值为100
- android:progress="50"
android:progress="50"
初始化的进度值
- android:secondaryProgress="70"
android:secondaryProgress="70"
初始化的底层第二个进度值
- android:layout_gravity="center_vertical"
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
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);
requestWindowFeature(Window.FEATURE_PROGRESS);
//请求一个窗口进度条特性风格
- setContentView(R.layout.main);
- setProgressBarVisibility(true);
setContentView(R.layout.main); setProgressBarVisibility(true);
//设置进度条可视
②然后设置进度值
- setProgress(myProgressBar.getProgress() * 100);
setProgress(myProgressBar.getProgress() * 100);
//设置标题栏中前景的一个进度条进度值
- setSecondaryProgress(myProgressBar.getSecondaryProgress() * 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 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
ProgressBar 各种样式的更多相关文章
- WPF 自定义ProgressBar滚动条样式
一.前言 滚动条一般用于加载进度,我们在看视频的时候或者在浏览网页的时候经常能看到加载进度的页面.在程序开发中,默认的进度加载样式可能跟程序风格不太一样,或者加载进度的时候需要更改一下加载的样式.这个 ...
- 分享个新浪下载图片的ProgressBar进度样式
https://github.com/eltld/ImageLoadProgress2
- Android 常用控件自定义样式RadioButton、CheckBox、ProgressBar、
一.RadioButton / CheckBox 系统自带的RadioButton/CheckBox的样式,注定满足不了实际运用中的情况,有时候自定义自己的样式:此次把自己中工作学习过程中所学到的东西 ...
- Android中自定义ProgressBar
<ProgressBar android:id="@+id/more_vprogress_more" android:layo ...
- Android简单自定义圆形和水平ProgressBar
ProgressBar简介 继承于View类,直接子类有AbsSeekBar和ContentLoadingProgressBar,其中AbsSeekBar的子类有SeekBar和RatingBar,可 ...
- 【读书笔记《Android游戏编程之从零开始》】5.Android 游戏开发常用的系统控件(ProgressBar、Seekbar)
3.7 ProgressBar ProgressBar类官方文档地址:http://developer.android.com/reference/android/widget/ProgressBar ...
- 写一个自己定义进度颜色和圆形转动的ProgressBar(具体介绍)
先上图: 我们得自己定义ProgressBar的样式 <span style="white-space:pre"> </span><style nam ...
- 关于ProgressBar的美化问题
Android自带的ProgressBar其实也算不上丑陋,但是如果所有的App都使用一个模式的ProgressBar,那么估计用户就要崩溃了,打开任何一个App,擦,进度条都一模一样..有鉴于此,我 ...
- ProgressBar 基本介绍
简介 ProgressBar 继承自View,用于在界面上显示一个进度指示的界面. 1.ProgressBar有两个进度,一个是android:progress,另一个是android:seconda ...
随机推荐
- java集合之ArrayList的实现原理
1. ArrayList概述: ArrayList是List接口的可变数组的实现.实现了所有可选列表操作,并允许包括 null 在内的所有元素.除了实现 List 接口外,此类还提供一些方法来操作内部 ...
- Changing the Overridden Method’s Characteristics
修改重写方法的特征 在大多数情况下,我们重写(override)一个 virtual 方法是为了改变它的实现.然后,有时我们却想改变该 virtual 方法的其他的特征,这往往会带来一系列问题. 1) ...
- 百度面试题——top K算法
需求 从一亿个数据中,找出其中最小的10个数. 分析 最笨的方法就是将这一亿个数据,按从小到大进行排序,然后取前10个.这样的话,即使使用时间复杂度为nlogn的快排或堆排,由于元素会频繁的移动,效率 ...
- BZOJ 1877: [SDOI2009]晨跑 费用流
1877: [SDOI2009]晨跑 Description Elaxia最近迷恋上了空手道,他为自己设定了一套健身计划,比如俯卧撑.仰卧起坐等 等,不过到目前为止,他坚持下来的只有晨跑. 现在给出一 ...
- linux下文件编码的查看与修改
在Linux中查看文件编码可以通过vim编辑器来查看,在vim命令模式下输入如下命令即可: :set fileencoding //在vim中查看文件编码 如果你只是想查看其它编码格式的文件或者想解决 ...
- poj3415 Common Substrings(后缀数组,单调栈 | 后缀自动机)
[题目链接] http://poj.org/problem?id=3415 [题意] A与B长度至少为k的公共子串个数. [思路] 基本思想是将AB各个后缀的lcp-k+1的值求和.首先将两个字符串拼 ...
- 快速幂取模 POJ 3761 bubble sort
题目传送门 /* 题意:求冒泡排序扫描k次能排好序的全排列个数 数学:这里有一个反序列表的概念,bj表示在j左边,但大于j的个数.不多说了,我也是看网上的解题报告. 详细解释:http://blog. ...
- 【转】SQL Server T-SQL写文本文件
原文:http://www.nigelrivett.net/SQLTsql/WriteTextFile.html The are several methods of creating text fi ...
- Jquery DataTables warning : Requested unknown from the data source for row 0
昨天在做 Jquery DataTables 的时候,遇到的一个问题,我使用MVC,在tables上加入了一个actionlink的href.但是在运行起来的时候,报错: DataTables war ...
- java多线程之队列
1.注:先不看阻塞与否,这ReentrantLock的使用方式就能说明这个类是线程安全类. 2.线程安全的类,BlockingQueue,ConcurrentLinkedQueue.这些都是线程安全的 ...