MainActivity:

package com.ruru.dialogproject;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity implements Runnable {
LoadingDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btn_name).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new LoadingDialog(MainActivity.this);
dialog.setCanceledOnTouchOutside(false);
dialog.show();
new Thread(MainActivity.this).start();
}
});
}
public void run() {
try {
Thread.sleep();
dialog.dismiss();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

activity_main:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ruru.dialogproject.MainActivity">
<Button
android:id="@+id/btn_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>

LoadingDialog:

package com.ruru.dialogproject;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* Created by 27c1 on 2017/1/4.
*/
public class LoadingDialog extends Dialog {
private TextView tv;
/**
* style很关键
*/
public LoadingDialog(Context context) {
super(context, R.style.loadingDialogStyle);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_loading);
tv = (TextView) findViewById(R.id.tv);
tv.setText("正在上传.....");
LinearLayout linearLayout = (LinearLayout) this.findViewById(R.id.LinearLayout);
linearLayout.getBackground().setAlpha();
}
}

dialog_loading:


<?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:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="160dp"
android:layout_height="160dp"
android:background="@drawable/yuanjiao"
android:gravity="center"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent" />
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>

R.style.loadingDialogStyle:

<style name="loadingDialogStyle" parent="android:Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item><!--设置dialog的背景-->
<item name="android:windowFrame">@null</item><!--Dialog的windowFrame框为无-->
<item name="android:windowNoTitle">true</item><!--是否显示title-->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
<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">false</item><!--背景是否模糊显示-->
<item name="android:backgroundDimAmount">0.6</item><!--背景的灰度-->
</style>

drawable-yuanjiao:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#86222222" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>

效果:

关于样式:

<item name="android:windowFrame">@null</item> :Dialog的windowFrame框为无
<item name="android:windowIsFloating">true</item>:是否浮现在activity之上
<item name="android:windowIsTranslucent">false</item>:是否半透明
<item name="android:windowNoTitle">true</item>:是否显示title
<item name="android:windowBackground">@drawable/dia_bg</item>:设置dialog的背景
<item name="android:backgroundDimEnabled">true</item>背景是否模糊显示
<item name="android:backgroundDimAmount">0.6</item>背景的灰度

Window attributes属性详解

Android仿微信进度弹出框的实现方法的更多相关文章

  1. Android仿ios底部弹出框效果

    准备: public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton ...

  2. 【Android】各式各样的弹出框与对菜单键、返回键的监听

    Android自带各式各样的弹出框.弹出框也是安卓主要的组件之中的一个.同一时候安卓程序能够对菜单键.返回键的监听.但在安卓4.0之后就禁止对Home键的屏蔽与监听,强制保留为系统守护按键.假设非要对 ...

  3. Android的几种弹出框

    项目效果图: 新建一个项目,结构图如下所示: activity_main.xml: <?xml version="1.0" encoding="utf-8" ...

  4. ASP.NET中的几种弹出框提示基本方法

    NET程序的开发过程中,常常需要和用户进行信息交互,对话框的出现将解决了这些问题,下面是本人对常用对话框使用的小结,希望对大家有所帮助 我们在.NET程序的开发过程中,常常需要和用户进行信息交互,比如 ...

  5. Android仿IOS底部弹出选择菜单ActionSheet

    使用Dialog的实现方式,解决原ActionSheet使用Fragment实现而出现的部分手机取消按钮被遮盖的问题 java部分代码: import android.app.Dialog; impo ...

  6. ThickBox弹出框的使用方法

    原文发布时间为:2009-08-22 -- 来源于本人的百度文章 [由搬家工具导入] 请访问:http://www.blueidea.com/articleimg/2007/12/5182/tickb ...

  7. android自定义弹出框样式实现

    前言: 做项目时,感觉Android自带的弹出框样式比较丑,很多应用都是自己做的弹出框,这里也试着自己做了一个. 废话不说先上图片: 实现机制 1.先自定义一个弹出框的样式 2.自己实现CustomD ...

  8. 自动化测试-12.selenium的弹出框处理

    前言 不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert.先认清楚alert长什么样子,下次碰到了,就可以用对应方法解决. alert\confirm\prompt ...

  9. [js]uploadify结合jqueryUI弹出框上传,js中的冒出的bug,又被ie坑了

    引言 最近在一个项目中,在用户列表中需要对给没有签名样本的个别用户上传签名的样本,就想到博客园中上传图片使用弹出框方式,博客园具体怎么实现的不知道,只是如果自己来弄,想到两个插件的结合使用,在弹出框中 ...

随机推荐

  1. Double 与 Float 的值的比較结果

    首先看geeksforgeeks上的两个程序: 程序1: #include<stdio.h> int main() { float x = 0.1; if (x == 0.1) print ...

  2. 从ORA-27300,ORA-27301到ORA-00064

        近期因为session数量添加,须要调整session,也就是要调整process參数. 看是比較简单的一个问题,却遭遇了ORA-27300,ORA-27301.因为这个涉及到了有关内核參数k ...

  3. 模拟实现Spring IoC功能

    为了加深理解Spring 今天自己写了一个模拟的Spring.... 步骤: 1.利用jdom解析bean.xml(pull,sax也能够,我这里用了jdom) 2.先解析全部的<bean/&g ...

  4. (转)C/C++ 宏详解

    众多C++书籍都忠告我们C语言宏是万恶之首,但事情总不如我们想象的那么坏,就如同goto一样.宏有一个很大的作用,就是自动为我们产生代码.如果说模板可以为我们产生各种型别的代码(型别替换),那么宏其实 ...

  5. java基础——static keyword小节

    static 用于修饰成员 修饰成员变量和成员函数 被修饰过的成员的特点:   1.随着类的载入而载入   2.优先于对象而存在   3.被全部对象所共享   4.能够直接被类名调用

  6. HttpWebRequest 表单提交

    /// <summary> /// http请求 /// </summary> public static class ZkWebRequestHelp { /// <s ...

  7. MySQL内置函数uuid和uuid_short

    MySQL的uuid这个函数.简要介绍一下. 用法 简单看到,这个值,每次执行都是不同的. 生成规则 第1 2 3 段是与时间有关的. time_low.time_mid.time_high_and_ ...

  8. Servlet学习(二)——ServletContext对象

    1.什么是ServletContext对象 ServletContext代表是一个web应用的环境(上下文)对象,ServletContext对象内部封装是该web应用的信息,一个web应用只有一个S ...

  9. hdu 1051 - 贪心,水题

    题目链接 一堆小木棍,每个有两个属性值(l,w),对小木棍分组,每一组内的小木棍存在这样一个序列满足s1<=s2<=s3.....<=sn,[s1<=s2当且仅当s1.l< ...

  10. SpringCloud学习笔记(20)----Spring Cloud Netflix之服务网关Zuul的各种姿势

    1. 禁用过滤器 # zuul.<SimpleClassName>.<filterType>.disable=true # 例如禁用 自定义的过滤器 zuul.MyFilter ...