ProgressBar的使用
2015-09-08 12:37
274 查看
ProgressBar的使用 1.简单使用 <ProgressBar style="?android:attr/progressBarStyleHorizontal" //条状 android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/progressBar" /> <ProgressBar style="?android:attr/progressBarStyleLarge" //大圈 android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/progressBar2" /> <ProgressBar //正常圈 android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/progressBar3" /> <ProgressBar style="?android:attr/progressBarStyleSmall" //小圈 android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/progressBar4" /> 2.标题栏上的进度条 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); //这句应在setContentView的前面 setContentView(R.layout.activity_main); setProgressBarIndeterminateVisibility(true); 3.对话框进度条 <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="对话框进度条" android:onClick="showDialogProgress"/> public void showDialogProgress(View v){ ProgressDialog pd = new ProgressDialog(this); // 设置进度条的最大值 pd.setMax(150); // 是否是确定的进度条 pd.setIndeterminate(false); // 设置进度条的title pd.setTitle("Title"); // 设置对话框的提示信息 pd.setMessage("waiting..."); // 设置进度条样式 pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); // 设置对话框是否可以被取消 pd.setCancelable(true); pd.show(); // 设置进度条的进度,注意得放在show方法后面才行 pd.setProgress(100); } 4.自定义进度条 <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminateDrawable="@drawable/progress_bg"/> 在drawable目录下新建resource file 并将根节点改为 layer-list <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <rotate android:drawable="@mipmap/ba" android:fromDegrees="0" android:pivotX="50%" //转动的圆心 android:pivotY="50%" android:toDegrees="360"></rotate> </item> </layer-list>
相关文章推荐
- ACM大赛题 【C++大数相乘】
- 2015年 【华为c++技术面试题】找出重复的数字
- 【win10+vs2013+opencv3.0安装与配置的详细过程】
- TCP/IP、Http、Socket的区别
- hibernate的三种查询
- 在高德地图应用api,和api展出的标记小的应用程序
- 管道符
- OSChina上部署项目 — iOS
- Linux命令学习(三)-配置有线网卡ip地址
- Beego环境搭建和bee工具安装使
- python和ruby语法的简单对比
- PowerDesigner中name与comment互相转换脚本
- 设计模式-六大原则
- 【Android报错之一】finished with non-zero exit value 2
- lintcode-有多少个点在同一条直线上-186
- JBPM具体应用之decision节点的使用
- TortoiseGit 不用每次输入用户名和密码的方法
- java基础:位运算用法测试代码
- Android中级教程之----Log图文详解(Log.v,Log.d,Log.i,Log.w,Log.e)
- 有限责任公司股权激励范例:股权期权协议书