原文地址:ProgressDialog集锦及各种效果作者:heaven

1,弹出Dialog 屏幕不变暗。

创建一个样式就OK了:在styles.xml文件里添加样式:

1,

<style name="dialog" parent="@android:style/Theme.Dialog">
        <item name="android:windowFrame">@null</item>边框
        <item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
        <item name="android:windowIsTranslucent">false</item><!--半透明-->
        <item name="android:windowNoTitle">true</item><!--无标题-->
     <!--    <item name="android:windowBackground">@color/transparent</item>背景透明   去掉背景色边框也就去掉了 -->
        <item name="android:backgroundDimEnabled">false</item><!--模糊-->
        <!-- <item name="android:windowContentOverlay">@null</item> -->
    </style>

-------------------------------------------------------------------------------

提示一个属性:

<item name="android:backgroundDimAmount">0.8</item><!-- android:backgroundDimAmount就是用来控制灰度的值,当为1时,界面除了我们的dialog内容是高亮显示的,dialog以外的区域是黑色的,完全看不到其他内容,系统的默认值是0.5,而已根据自己的需要调整
         -->

2,

创建ProgressDialog 时,设置样式   通过系统的ProgressDialog 是有白色边框的。

ProgressDialog loading_Dialog = new ProgressDialog(MainActivity.this,R.style.dialog);

loading_Dialog.show();

其他属性自己设置哟!!

-----------------------------------------------------------------------------------------------

没有白色边框的时候:

xml文件: customprogressdialog.xml

http://schemas.android.com/apk/res/android"
    android:layout_width="160dip"
    android:layout_height="60dip"
    android:gravity="center"
    android:layout_gravity="center"
    android:orientation="horizontal"
    >

android:id="@+id/progressBar1"
        android:layout_width="40dip"
        android:layout_height="40dip"
        />
   
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Loading....."
        android:textColor="@android:color/white"
        />

自定义dialog

public class CustomProgressDialog extends ProgressDialog {

public CustomProgressDialog(Context context) {
  super(context);
 }
  public CustomProgressDialog(Context context,int theme) { 
           super(context,theme); 
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.customprogressdialog);
  
//  setContentView(android.R.layout.alert_dialog_progress);
  
 }

public static CustomProgressDialog show (Context context) { 
   CustomProgressDialog dialog = new CustomProgressDialog(context,R.style.dialog);
   dialog.show();
   return dialog;
  }
 
}

代码中调用:

CustomProgressDialog loading_Dialog = new CustomProgressDialog(MainActivity.this,R.style.dialog);

这个是改变Dialog的背景透明度:

  Window wd= loading_Dialog.getWindow();
  WindowManager.LayoutParams lp = wd.getAttributes();
  lp.alpha = 0.5f;
  wd.setAttributes(lp);
  //lp.alpha = 0.5f 设置透明度,值可以自己测试

loading_Dialog.show();

效果图:

------------------------------------------------------------------------------------

2, 改变ProgressDialog 的旋转图片:

   该图片的名字为  image_progress

1,定义一个图片资源文件: 在drawable目录下新建一个 progress.xml

<?xml version="1.0" encoding="utf-8"?>
      <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:drawable="@drawable/image_progress"   
        android:pivotX="50%"
        android:pivotY="50%" />

2,定义一个布局文件layout   layout_progress.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

<ProgressBar
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:indeterminateDrawable="@drawable/progress" />     需要旋转的图片

</LinearLayout>

3,在Activity中    自己试下这2中效果。

第一种方法,自己就会旋转:

setContentView(R.layout.layout_progress);
        第二种方法:
               //        ProgressDialog dialog = new ProgressDialog(this);
               //        dialog.show();
               //        dialog.setContentView(R.layout.layout_progress);

效果图:

                                     

---------------------------------------------------------------------------------------------

3,自定义progressbar颜色:

1,定义一个图片资源文件: 在drawable目录下新建一个 dialog_imag_color.xml

<?xml version="1.0" encoding="utf-8"?>
<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="#FFFFFF"
            android:centerY="0.50"
            android:endColor="#FFFF00"
            android:startColor="#000000"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

2,定义一个布局文件: layout_progress.xml 这个是在上一个布局的基础上有添加了一个progressBar

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<ProgressBar
        android:layout_marginTop="90dip"
        android:layout_gravity="center"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:indeterminateDrawable="@drawable/progress" />

<ProgressBar
        android:id="@+id/color_progressBar2"
         android:layout_marginTop="90dip"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminateDrawable="@drawable/dialog_imag_color" />

</LinearLayout>

效果图:


------------------------------------------------------------------------------------------------

水平的ProgressBar    看先样式的源码: style="@android:style/Widget.ProgressBar.Horizontal"

1,样式

2,progressDrawable 重写   android:progressDrawable="@drawable/progerss_horizontal"

xml代码文件:

<ProgressBar

android:id="@+id/progressBar1"

style="@android:style/Widget.ProgressBar.Horizontal"

android:layout_width="fill_parent"

android:layout_height="30dip"

android:layout_alignParentRight="true"

android:layout_below="@+id/button2"

android:layout_margin="15dp"

android:background="@drawable/guild_member_item_default"

android:progressDrawable="@drawable/progerss_horizontal" />

progerss_horizontal 文件

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:id="@android:id/background">

<clip android:drawable="@drawable/guild_member_item_default" ></clip>

</item>

<item android:id="@android:id/secondaryProgress">

<clip android:drawable="@drawable/guild_member_item_press" ></clip>

</item>

<item android:id="@android:id/progress">

<clip android:drawable="@drawable/guild_member_item_press" ></clip>

</item>

</layer-list>

效果图:

圆圈的ProgressBar   android:indeterminateDrawable

样式源代码: 看下标红的地方。如果有时间看下系统apiDemo里面有关这块demo源码。

- <style name="Widget.ProgressBar">
  <item name="android:indeterminateOnly">true</item>
  <itemname="android:indeterminateDrawable">@android:drawable/progress_medium_white</item>
  <item name="android:indeterminateBehavior">repeat</item>
  <item name="android:indeterminateDuration">3500</item>
  <item name="android:minWidth">48dip</item>
  <item name="android:maxWidth">48dip</item>
  <item name="android:minHeight">48dip</item>
  <item name="android:maxHeight">48dip</item>
  </style>

- <style name="Widget.ProgressBar.Large">
  <item name="android:indeterminateDrawable">@android:drawable/progress_large_white</item>
  <item name="android:minWidth">76dip</item>
  <item name="android:maxWidth">76dip</item>
  <item name="android:minHeight">76dip</item>
  <item name="android:maxHeight">76dip</item>
  </style>

- <style name="Widget.ProgressBar.Small">
  <itemname="android:indeterminateDrawable">@android:drawable/progress_small_white</item>
  <item name="android:minWidth">16dip</item>
  <item name="android:maxWidth">16dip</item>
  <item name="android:minHeight">16dip</item>
  <item name="android:maxHeight">16dip</item>
  </style>

- <style name="Widget.ProgressBar.Inverse">
  <item name="android:indeterminateDrawable">@android:drawable/progress_medium</item>
  </style>

- <style name="Widget.ProgressBar.Large.Inverse">
  <item name="android:indeterminateDrawable">@android:drawable/progress_large</item>
  </style>

- <style name="Widget.ProgressBar.Small.Inverse">
  <item name="android:indeterminateDrawable">@android:drawable/progress_small</item>
  </style>

- <style name="Widget.ProgressBar.Small.Title">
  <itemname="android:indeterminateDrawable">@android:drawable/progress_small_titlebar</item>
  </style>

- <style name="Widget.ProgressBar.Horizontal">
  <item name="android:indeterminateOnly">false</item>
  <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
  <itemname="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
  <item name="android:minHeight">20dip</item>
  <item name="android:maxHeight">20dip</item>
  </style>

- <style name="Widget.SeekBar">
  <item name="android:indeterminateOnly">false</item>
  <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
  <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
  <item name="android:minHeight">20dip</item>
  <item name="android:maxHeight">20dip</item>
  <item name="android:thumb">@android:drawable/seek_thumb</item>
  <item name="android:thumbOffset">8dip</item>
  <item name="android:focusable">true</item>
  </style>

- <style name="Widget.RatingBar">
  <item name="android:indeterminateOnly">false</item>
  <item name="android:progressDrawable">@android:drawable/ratingbar_full</item>
  <item name="android:indeterminateDrawable">@android:drawable/ratingbar_full</item>
  <item name="android:minHeight">57dip</item>
  <item name="android:maxHeight">57dip</item>
  <item name="android:thumb">@null</item>
  </style>

[转载]ProgressDialog集锦及各种效果相关推荐

  1. android 同根动画_[转载]Android anim动画切换效果

    关于动画的实现,Android提供了Animation,在Android SDK介绍了2种Animation模式: 1. Tween Animation:通过对场景里的对象不断做图像变换(平移.缩放. ...

  2. kankan转载:anddroid卡牌效果实现

    本文介绍如何是一个自定义的Fragment动画来制作卡片翻转动画.卡片翻转动画是在内容视图之间模拟卡片翻转的效果. 创建动画器 创建用于卡片翻转的动画,需要两个用于前景的动画器,它们会让卡片的前景向左 ...

  3. html锚点滑动效果,【转载】HTML锚点效果改进平滑移动页面滚动特效实现技术

    目 前市面上有很多网站的链接上都带有锚点,锚点的作用是当用户到达这个页面后,可以快速的定位到某个元素的位置.使用锚点后,一旦网页加载完成,页面就会快 速的滚动到锚点处,如果锚点在页面底部,则页面将滚动 ...

  4. 阿里云AI如何助攻世界杯?视频集锦背后的技术实践

    摘要: 本届世界杯互联网直播的顺利进行,离不开各大云计算厂商的支持.在这其中,阿里云是当之无愧的"C位",除了优酷外,阿里云还支撑了CNTV.CCTV5客户端,为全网70%的世界杯 ...

  5. css2.0圆角,CSS圆角效果-CSS3常用属性集合

    CSS3使用注意项:早期的firefox chrome 等某些游览器中也实现了部分CSS3,所以为了兼容部分,在CSS3中的编写,需要如此: {-moz-border-radius: 4px; -we ...

  6. Android新浪微博client(七)——ListView图片异步加载、高速缓存

    原文出自:方杰|http://fangjie.sinaapp.com/?p=193 转载请注明出处 终于效果演示:http://fangjie.sinaapp.com/?page_id=54 该项目代 ...

  7. handsome对应php文件,handsome主题魔改教程

    !> 魔改效果详见本站,CSS由 神代綺凜 原创编写,已获得作者转载授权. 魔改效果 有没有觉得很酷炫? 那么我们快搞起! 魔改教程 第一步 下载CSS [button icon="g ...

  8. 常见的网络品牌营销的方法和渠道

    伴随着互联网的发展成熟,网络已经成为生活的必需品,这也逐渐成为一个商业聚居之地.无论你是企业,还是个人,如果想在互联网的浪潮中拥有一席之地之地,那么网络营销就是的必经之路.为大家分享的一些常用的网络营 ...

  9. 【Markdown语法】字体颜色大小及文字底色设置

    Markdown字体颜色大小设置 一.更改字体.颜色.大小 1.Markdown语法 2.一些常用颜色 3.文字底色 二.some tips 1.强调 2.放大加粗字体(类似于标题) 3.分割线 4. ...

最新文章

  1. linux 系统管理(二) 磁盘分区
  2. LeetCode SQL 196. 删除重复的电子邮箱
  3. 2.privite私有变量的意义
  4. Win-MASM64汇编语言-visual studio下环境搭建
  5. 每日算法系列【LeetCode 153】寻找旋转排序数组中的最小值
  6. 前端工程师-JavaScript
  7. 2009开源SNS软件总结
  8. 常用触摸屏485通讯引脚及下载口
  9. 答复达内同学 2007-08-11
  10. 链表排序python
  11. make menuconfig快速查找
  12. 委托、事件 茴字有几种写法
  13. 一文揭开ALBERT的神秘面纱
  14. qq机器人插件之奥运奖牌获得数量
  15. 如何绘制业务架构图 — 1. 概述
  16. 服务器托管的必要性(下)
  17. 视频存储价格高昂_避免5个最常见(且代价高昂)的错误,这些错误肯定会导致游戏出轨...
  18. 许昌学院计算机专业是几本,2017年许昌学院是几本?许昌学院怎么样?
  19. 连续信号希尔伯特变换
  20. 网站安全监测报告 预测2020年的网络安全发展趋势

热门文章

  1. Linux用7zip解压缩7z分卷文件
  2. 计算机基础应用win7,计算机应用基础WIN7第一章.ppt
  3. 超越Teamviewer,使用开源软件Rustdesk自建服务器实现远程桌面连接(10分钟包教会,超详细教程)
  4. Unity 3D 消息事件系统 NotificationCenter、CEventDispatcher事件分发机制
  5. 几楼电路精灵——Cadence Allegro 自动摆放位号
  6. Flutter的国际化方式
  7. (十二)【数电】(组合逻辑电路)加法器
  8. 关于reverse函数
  9. 数据仓库概念和项目架构
  10. MongoDB的update更新使用方法