Android仿微信进度弹出框的实现方法
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仿微信进度弹出框的实现方法的更多相关文章
- Android仿ios底部弹出框效果
准备: public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton ...
- 【Android】各式各样的弹出框与对菜单键、返回键的监听
Android自带各式各样的弹出框.弹出框也是安卓主要的组件之中的一个.同一时候安卓程序能够对菜单键.返回键的监听.但在安卓4.0之后就禁止对Home键的屏蔽与监听,强制保留为系统守护按键.假设非要对 ...
- Android的几种弹出框
项目效果图: 新建一个项目,结构图如下所示: activity_main.xml: <?xml version="1.0" encoding="utf-8" ...
- ASP.NET中的几种弹出框提示基本方法
NET程序的开发过程中,常常需要和用户进行信息交互,对话框的出现将解决了这些问题,下面是本人对常用对话框使用的小结,希望对大家有所帮助 我们在.NET程序的开发过程中,常常需要和用户进行信息交互,比如 ...
- Android仿IOS底部弹出选择菜单ActionSheet
使用Dialog的实现方式,解决原ActionSheet使用Fragment实现而出现的部分手机取消按钮被遮盖的问题 java部分代码: import android.app.Dialog; impo ...
- ThickBox弹出框的使用方法
原文发布时间为:2009-08-22 -- 来源于本人的百度文章 [由搬家工具导入] 请访问:http://www.blueidea.com/articleimg/2007/12/5182/tickb ...
- android自定义弹出框样式实现
前言: 做项目时,感觉Android自带的弹出框样式比较丑,很多应用都是自己做的弹出框,这里也试着自己做了一个. 废话不说先上图片: 实现机制 1.先自定义一个弹出框的样式 2.自己实现CustomD ...
- 自动化测试-12.selenium的弹出框处理
前言 不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert.先认清楚alert长什么样子,下次碰到了,就可以用对应方法解决. alert\confirm\prompt ...
- [js]uploadify结合jqueryUI弹出框上传,js中的冒出的bug,又被ie坑了
引言 最近在一个项目中,在用户列表中需要对给没有签名样本的个别用户上传签名的样本,就想到博客园中上传图片使用弹出框方式,博客园具体怎么实现的不知道,只是如果自己来弄,想到两个插件的结合使用,在弹出框中 ...
随机推荐
- 基于Dragon Board410c 的智能机器人预研-语音识别及定位
转自:http://www.csdn.net/article/a/2016-01-06/15833642 一.前言 机器人是一种可编程和多功能的.用来搬运材料.零件.工具的操作机,智能机器人则是一个在 ...
- Android 开发之集成百度地图的定位与地图展示
app 应用中,大多数应用都具有定位功能,百度定位就成了开发人员的集成定位功能的首选,近期也在做定位功能,可是发现百度真是个大坑啊, sdk 命名更新了,相关代码却不更新,害得我花费了非常长时间来研究 ...
- apiCloud中openFrameGroup传参
apiCloud中openFrameGroup传参 1.无效的 api.openFrameGroup({ // 打开 frame 组 name: 'group', scrollEnabled: fal ...
- 4K 对齐与固态硬盘检测工具
0. 硬盘扇区 当前电脑传统机械硬盘的每个扇区一般大小为 512 字节(512B):当使用某一文件系统将硬盘格式化时,文件系统会将硬盘扇区.磁道与柱面统计整理并定义一个簇为多少扇区方便快速存储. 现时 ...
- Array数组的排序与二分查字法
import java.util.Arrays; public class sort { public static void main(String[] args) { // TODO 自动生成的方 ...
- (转载) android快速搭建项目积累
android快速搭建项目积累 2016-04-05 20:07 519人阅读 评论(0) 收藏 举报 分类: android优化(8) Rx技术(5) 版权声明:本文为博主原创文章,未经博主 ...
- android全屏去掉title栏的多种实现方法
android全屏去掉title栏的多种实现方法 作者: 字体:[增加 减小] 类型:转载 时间:2013-02-18我要评论 android全屏去掉title栏包括以下几个部分:实现应用中的所有ac ...
- JS自定义全局Error
<script> ///自定义错误 onerror=handleErr; function handleErr(msg,url,l) { var txt=""; txt ...
- CodeForces-766D Mahmoud and a Dictionary 并查集 维护同类不同类元素集合
题目链接:https://cn.vjudge.net/problem/CodeForces-766D 题意 写词典,有些词是同义词,有些是反义词,还有没关系的词 首先输入两个词,需要判断是同义还是是反 ...
- layui框架下的摸索与学习
一.table表格内的查询 1.单个条件查询: 主要代码: <%-- Created by IntelliJ IDEA. User: Administrator Date: 2019/1/14 ...