自定义progressbar

<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:indeterminateDrawable="@drawable/progressbar" />
progressbar.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" > <shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<gradient
android:centerColor="@color/title_color"
android:centerY="0.50"
android:endColor="@color/title_color"
android:startColor="@color/transparent"
android:type="sweep"
android:useLevel="false" />
</shape> </animated-rotate>
全部代码
<style name="Animation.Dialog">
<item name="windowEnterAnimation">@anim/dialog_enter</item>
<item name="windowExitAnimation">@anim/dialog_exit</item>
</style>
<!-- 更多登录等待框的样式 -->
</style>
<style name="loadingDialogStyle" parent="android:Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<!-- 对话框是否有遮盖 -->
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
public class ThirdLoginLoadingDialog extends Dialog {
private TextView tv;
public ThirdLoginLoadingDialog(Context context) {
super(context, R.style.loadingDialogStyle);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_thirdlogin_dialog_loading);
tv = (TextView) this.findViewById(R.id.tv);
tv.setText("正在登录...");
LinearLayout linearLayout = (LinearLayout) this
.findViewById(R.id.LinearLayout);
linearLayout.getBackground().setAlpha(0);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" > <LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="160dp"
android:layout_height="160dp"
android:background="@drawable/thirdlogin_dialog_bg"
android:gravity="center"
android:orientation="vertical" > <ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:indeterminateDrawable="@drawable/progressbar" /> <TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:textColor="@android:color/white" />
</LinearLayout> </LinearLayout>
最后 在主活动中加上
private ThirdLoginLoadingDialog dialog;
dialog = new ThirdLoginLoadingDialog(this);
dialog.setCanceledOnTouchOutside(false);//防止触摸其他地方,程序报错
dialog.show();
dialog.dismiss();
自定义progressbar的更多相关文章
- Android ProgressBar分析及自定义ProgressBar
ProgressBar是在执行耗时操作时的一种人性化设计.分为两种形式:转圈的,能显示进度的. 而能取决于是什么样式的PregressBar,当然就是PregressBar的样式啦~ Widget.P ...
- Android三种实现自定义ProgressBar的方式介绍
一.通过动画实现 定义res/anim/loading.xml如下: View Row Code<?xml version="1.0" encoding="UTF- ...
- Android自定义ProgressBar样式
我们使用的进度条多种多样,下面有几种自定义的进度条的样式,下面介绍几个. 进度条的有基本的四种样式: 默认风格的进度条: android:progressBarStyle 水平长型进度条: andro ...
- 自定义ProgressBar的加载效果
三种方式实现自定义圆形页面加载中效果的进度条 To get a ProgressBar in the default theme that is to be used on white/light b ...
- android 自定义progressbar 样式
在res下创建drawable文件夹,新建文件drawable/progressbar_color.xml <layer-list xmlns:android="http://sche ...
- Android中自定义ProgressBar
<ProgressBar android:id="@+id/more_vprogress_more" android:layo ...
- 自定义progressBar的旋转圆圈
在手工打造下拉刷新功能 自带的progressBar太丑了 做个也不费事,一个简单的圆形 旋转动画加type是sweep的gradient渐变 <rotate //旋转动画xmlns:andro ...
- Android自定义progressBar
通过继承系统ProgressBar实现 效果图 实现 HorizontalProgressBarWithNumber 自定义属性 <?xml version="1.0" en ...
- android 项目学习随笔十(自定义ProgressBar)
android:innerRadius 内部半径 android:thickness 厚度 gradient 渐变 android:useLevel="false" 取掉控件自带旋 ...
随机推荐
- AsyncTask不能同时运行多个实例解决办法
在项目中使用AsyncTask时,发现创建的多个实例无法同时运行,比如: AsyncTask t1 = new MyTask(); AsyncTask t2 = new MyTask(); t1.ex ...
- Matlab中min/max函数的误解
1.C= min(a):返回最小值:我原来以为如果a是行向量,min(a)返回a本身,因为我记得min(a,1)是按列找最小,这是默认的.doc min发现,只要a是向量,那么返回最小值. 2.C= ...
- [51 nod]1009 数字1的数量
1009 数字1的数量 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给定一个十进制正整数N,写下从1开始,到N的所有正数,计算出其中出现所有1的个数. 例如: ...
- PHP开发框架[流行度排名]
在PHP开发中,选择合适的框架有助于加快软件开发,节约宝贵的项目时间,让开发者专注于功能的实现上.Sitepoint网站做了一个小的调查,结果显示最流行的PHP框架前三甲为:Laravel.Phalc ...
- 【Memcache】下载和安装
下载: Win7 64bit 系统 下载过过很多版本,都无法安装,最后到这里下载,成功安装: http://blog.couchbase.com/memcached-windows-64-bit-pr ...
- spoj 78
数学 组合 隔板法 #include <iostream> #include <cstring> #include <cstdio> #include <s ...
- JsRender系列demo(3)-自定义容器
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- 设计模式(Design Patterns——可复用面向对象软件的基础
设 计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代 码可靠性. 毫无疑问 ...
- no such partition grub rescue>
事出有因: 电脑系统是win7+ubuntu,然后在win7下把ubuntu的分区给删除了,重启,出现 no such partition grub rescue> 错误. 原因是双系统之前是由 ...
- Sina App Engine(SAE)入门教程(10)- Cron(定时任务)使用
参考资料 SAE Cron说明文档 Cron能干什么? cron 可以定时的触发一个脚本,在sae上最大的频率是一分钟一次.你可以用其来完成自己需要的业务逻辑,例如定期的抓取某些网页完菜信息的采集,定 ...