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>
  <item name="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">
  <item name="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>
 
一、ProgressBar教程

andriod ProgressBar 总结
http://www.eoeandroid.com/thread-182359-1-1.html

Android ProgressBar 几乎全部的用法
http://www.eoeandroid.com/thread-182369-1-1.html

Android多媒体实例大汇集(源码,全)!!!
http://www.eoeandroid.com/thread-71079-1-1.html

一个帖子掌握android所有控件、ProgressBar 、Android 动画效果...
http://www.eoeandroid.com/thread-182414-1-1.html

Android ProgressBar实现方式
http://www.eoeandroid.com/thread-182415-1-1.html

Android游戏开发系统控件-ProgressBar
http://www.eoeandroid.com/thread-182417-1-1.html

Android进度条(ProgressBar)拖动条(SeekBar)星级滑块(RatingBar)的例子
http://www.eoeandroid.com/thread-182418-1-1.html

Andorid---UI篇---两种进度条(ProgressBar)
http://www.eoeandroid.com/thread-182423-1-1.html

[PDF] 花样Android ProgressBar 史上最强大讲解
http://www.eoeandroid.com/thread-1081-1-1.html

【刚整理的】Android控件TextProgressBar进度条上显文字
http://www.eoeandroid.com/thread-40472-1-1.html

Android 在Java代码中设置style属性--使用代码创建ProgressBar对象
http://www.eoeandroid.com/thread-171872-1-1.html

Android自定义进度条-带文本(文字进度)的水平进度条(ProgressBar)
http://www.eoeandroid.com/thread-171875-1-1.html

简单实现自定义进度条(不用ProgressBar)
http://www.eoeandroid.com/thread-154015-1-1.html

用Handler更新进度条ProgressBar
http://www.eoeandroid.com/thread-169292-1-1.html

Android进度条(ProgressBar)拖动条(SeekBar)星级滑块(RatingBar)的例子
http://www.eoeandroid.com/thread-97899-1-1.html

分享Android的ProgressBar
http://www.eoeandroid.com/thread-82410-1-1.html

二、ProgressBar实例源码

Android 标题栏progressBar实例
http://www.eoeandroid.com/thread-81159-1-1.html

用Handler更新进度条ProgressBar
http://www.eoeandroid.com/thread-169292-1-1.html

Android自定义进度条-带文本(文字进度)的水平进度条(ProgressBar)
http://www.eoeandroid.com/thread-171875-1-1.html

关于实现类似于圆形ProgressBar的播放进度条
http://www.eoeandroid.com/thread-99172-1-1.html

教你打造自定义ProgressBar样式
http://www.eoeandroid.com/thread-182508-1-1.html

在ProgressBar上加文字----显示百分比的进度条
http://www.eoeandroid.com/thread-182511-1-1.html

Android 控件之ProgressBar进度条
http://www.eoeandroid.com/thread-182513-1-1.html

android圆形进度条ProgressBar颜色设置
http://www.eoeandroid.com/thread-182514-1-1.html

Android控件TextProgressBar进度条上显文字
http://www.eoeandroid.com/thread-182516-1-1.html

很给力的ProgressBar 有各种样式
http://www.eoeandroid.com/thread-182519-1-1.html

带文字的ProgressBar--含代码
http://www.eoeandroid.com/thread-84258-1-1.html

eoe & 友盟教程大赛【进度条和界面跳转的实现】
http://www.eoeandroid.com/thread-164906-1-1.html

自定义ProgressBar
http://www.eoeandroid.com/thread-68458-1-1.html

三、ProgressBar常见问题与解决
怎么在页面联网的时候显示旋转的loading条,ProgressBar【已解决】
http://www.eoeandroid.com/thread-3245-1-1.html

关于ProgressBar【已解决】
http://www.eoeandroid.com/thread-41015-1-1.html

ProgressBar的style不在xml文件里设置,怎么动态设置啊?【已解决】
http://www.eoeandroid.com/thread-34621-1-1.html

以线程运行android进度条【已解决】
http://www.eoeandroid.com/thread-41133-1-1.html

圆形progressbar 处理手法问题。。【已解决】
http://www.eoeandroid.com/thread-166894-1-1.html

求助,用handler设置progressbar的可见性时报错。【已解决】
http://www.eoeandroid.com/thread-154844-1-1.html

求一控件效果,关于button和progressbar的【已解决】
http://www.eoeandroid.com/thread-156124-1-1.html

关于Gallery显示Progressbar的问题【已解决】
http://www.eoeandroid.com/thread-161530-1-1.html

android ProgressBar修改【已解决】
http://www.eoeandroid.com/thread-151051-1-1.html

重金悬赏,怎样修改ListView 里面的ProgressBar【已解决】
http://www.eoeandroid.com/thread-74817-1-1.html

四、ProgressBar未解决问题
怎么把CheckBox和ProgressBar结合使用【未解决】
http://www.eoeandroid.com/thread-2005-1-1.html

Android progressdialog的问题...【未解决】
http://www.eoeandroid.com/thread-23529-1-1.html

android中的配置文件如何用代码表现【未解决】
http://www.eoeandroid.com/thread-45849-1-1.html

怎麼用Handler 來更新ProgressBar的进度【未解决】
http://www.eoeandroid.com/thread-90406-1-1.html

ProgressBar的显示问题!【未解决】
http://www.eoeandroid.com/thread-63412-1-1.html

五、关于ProgressBar的一点设想
请问:进度条ProgressBar是否只是浮云?

http://www.eoeandroid.com/thread-39624-1-1.html

来自:http://www.eoeandroid.com/thread-172018-1-1.html

Android多媒体实例大汇集(源码,全)!!!经过两个星期的多媒体学习,实现了一系列DEMO,几乎涵盖了Android中对媒体中的各个方面(当然底层除外)。
http://www.eoeandroid.com/thread-71079-1-1.html

[PDF] 花样Android ProgressBar 史上最强大讲解
http://www.eoeandroid.com/thread-1081-1-1.html

Android学习笔记_81_Android ProgressDialog ProgressBar 各种效果的更多相关文章

  1. android学习笔记20——ProgressDialog进度条对话框

    ProgressDialog==>进度条对话框 ProgressDialog本身就代表一个进度条对话框,程序只需要创建ProgressDialog实例,并将其显示出来就是一个进度条对话框:开发者 ...

  2. 【转】 Pro Android学习笔记(四二):Fragment(7):切换效果

    目录(?)[-] 利用setTransition 利用setCustomAnimations 通过ObjectAnimator自定义动态效果 程序代码的编写 利用fragment transactio ...

  3. android学习笔记36——使用原始XML文件

    XML文件 android中使用XML文件,需要开发者手动创建res/xml文件夹. 实例如下: book.xml==> <?xml version="1.0" enc ...

  4. Android学习笔记之JSON数据解析

    转载:Android学习笔记44:JSON数据解析 JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,为Web应用开发提供了一种 ...

  5. Pro Android学习笔记 ActionBar(1):Home图标区

     Pro Android学习笔记(四八):ActionBar(1):Home图标区 2013年03月10日 ⁄ 综合 ⁄ 共 3256字 ⁄ 字号 小 中 大 ⁄ 评论关闭 ActionBar在A ...

  6. 【转】 Pro Android学习笔记(三五):Menu(6):XML方式 & PopUp菜单

    目录(?)[-] 利用XML创建菜单 XML的有关属性 onClick事件 Pop-up菜单 利用XML创建菜单 在代码中对每个菜单项进行设置,繁琐且修改不灵活,不能适配多国语言的要求,可以利用资源进 ...

  7. 【转】 Pro Android学习笔记(二九):用户界面和控制(17):include和merge

    目录(?)[-] xml控件代码重用include xml控件代码重用merge 横屏和竖屏landsacpe portrait xml控件代码重用:include 如果我们定义一个控件,需要在不同的 ...

  8. 【转】Pro Android学习笔记(二三):用户界面和控制(11):其他控件

    目录(?)[-] Chronometer计时器控件 倒计时CountDownTimer Switch控件 Space控件 其他控件 Android提供了很多控件,基本上都是view的扩展. Chron ...

  9. 【转】Pro Android学习笔记(三):了解Android资源(上)

    在Android开发中,资源包括文件或者值,它们和执行应用捆绑,无需在源代码中写死,因此我们可以改变或替换他们,而无需对应用重新编译. 了解资源构成 参考阅读Android学习笔记(三八):资源res ...

随机推荐

  1. jar包、jdk版本、兼容性

    对jar包.jdk版本,以及不同jdk版本的jar包的兼容性有一些疑问,搜集一些资料于此 查看jar包的jdk版本 查看.jar包中的META-INF\MANIFEST.MF Build-Jdk: 1 ...

  2. TOJ 1258 Very Simple Counting

    Description Let f(n) be the number of factors of integer n. Your task is to count the number of i(1 ...

  3. TOJ 2641 Gene

    描述 How can millions of different and complex structures be built using only a few simple building bl ...

  4. C++ Memory System Part1: new和delete

    在深入探索自定义内存系统之前,我们需要了解一些基础的背景知识,这些知识点是我们接下来自定义内存系统的基础.所以第一部分,让我们来一起深入了解一下C++的new和delete家族,这其中有很多令人吃惊的 ...

  5. nyoj 1197——你会加吗?——————【快速幂、分治】

    你会加吗? 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 给出两个整数A和N,计算(A + A^2 + A^3 + …… + A^(N - 1) + A^N)% 6 ...

  6. 自定义django admin及其界面

    1.在项目目录下新创建一个app,命名为kingadmin,在templates目录下新建kingadmin目录,用来存放相关页面的模板文件,新建一个templatetags目录,用来存放处理前端模板 ...

  7. 【Elasticsearch】集群管理

    8.1 Elasticsearch时光机 Elasticsearch的快照,防止出错,灾备8.1.1 创建快照存储库创建快照之前必须建一个存储库,有如下几个方面,name,type,settings, ...

  8. 如何优化VMWare虚拟机的运行速度(转)

    虚拟机是个好东西,但是对电脑有一定的要求.尤其对做工控的来说都需要安装一些大型的软件(其中WINCC最难装,对系统要求较高.而且像WIN 7 64位的就别想装上去了,如果改系统后那4G以上的内存不就浪 ...

  9. JS中的prototype(转载)

    本文转载自博客园. 作者:叶剑锋 出处:http://www.cnblogs.com/yjf512/archive/2011/06/03/2071914.html 本文基于下面几个知识点: 1 原型法 ...

  10. Sql Server 锁 排它锁 更新锁 共享锁

    引用别人的.有时间整体整理下. 引用地址:http://www.cnblogs.com/wenjl520/archive/2012/08/24/2654412.html 锁的概述 一. 为什么要引入锁 ...