自定义一个全屏的AlertDialog。
...........
final MyDialog dialog = new MyDialog(this);
LayoutInflater inflater = getLayoutInflater();
LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.layout, null);
CautionTv = (TextView) layout.findViewById(R.id.ion_tv);
ContentTv = (TextView) layout.findViewById(R.id.ntent_tv);
LanguageTv = (TextView) layout.findViewById(R.id.guage_tv);
OkBt = (Button) layout.findViewById(R.id._ok_bt);
OkBt.setOnClickListener(new OnClickListener() { @Override
public void onClick(View arg0) {
if (dialog != null) {
dialog.cancel();
}
}
});
dialog.show();
dialog.setCancelable(false);
dialog.setContentView(layout);// show方法要在前面
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams; import com.android.launcher.R; /**
* 自定义弹框
* @author xiebin
*
*/
public class MyDialog extends AlertDialog {
Context mContext; public MyDialog(Context context) {
super(context, R.style.MyDialog); // 自定义全屏style
this.mContext=context;
} @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
} @Override
public void show() {
super.show();
/**
* 设置宽度全屏,要设置在show的后面
*/
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.gravity=Gravity.BOTTOM;
layoutParams.width= LayoutParams.MATCH_PARENT;
layoutParams.height= LayoutParams.MATCH_PARENT;
getWindow().getDecorView().setPadding(, , , );
getWindow().setAttributes(layoutParams);
}
}
/Launcher/res/values/styles.xml
<!-- 全屏style -->
<style name="MyDialog" parent="@android:style/Theme.NoTitleBar.Fullscreen">
<!-- 是否有边框 -->
<item name="android:windowFrame">@null</item>
<!--是否在悬浮Activity之上 -->
<item name="android:windowIsFloating">true</item>
<!--标题 -->
<item name="android:windowNoTitle">true</item>
<!--阴影 -->
<item name="android:windowIsTranslucent">true</item><!--半透明-->
<!-- 点外边可以消失 -->
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
自定义一个全屏的AlertDialog。的更多相关文章
- 使用AVPlayer自定义支持全屏的播放器(五)—Swift重构版本
前言 很早之前开源了一个简单的视频播放器,由于年久失修,效果惨目忍睹,最近特意花时间对其进行了深度重构.旧版本后期不再维护,新版本使用Swift实现,后续会增加更多功能.不想看文字的请自行下载代码-- ...
- javascript自定义一个全类型读取的函数
我爱撸码,撸码使我感到快乐!大家好,我是Counter.因为我们知道,在JavaScript中有自带的方法可以读取类型,但是不很全面,今天来分享下如何自己定义一个函数,将所有传入参数的类型给打印出来, ...
- 关于最近在做的一个js全屏轮播插件
最近去面试了,对方要求我在一个星期内用原生的js代码写一个全屏轮播的插件,第一想法就是跟照片轮播很相似,只是照片轮播是有定义一个宽高度大小已经确定了的容器用来存储所有照片,然后将照片全部左浮动,利用m ...
- iOS开发——实用技术OC篇&8行代码教你搞定导航控制器全屏滑动返回效果
8行代码教你搞定导航控制器全屏滑动返回效果 前言 如果自定了导航控制器的自控制器的leftBarButtonItem,可能会引发边缘滑动pop效果的失灵,是由于 self.interactivePop ...
- echarts 饼图 + 全屏显示
效果图: 代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- 弹出iframe内嵌页面元素到父页面并全屏化
(注册博客好久了,一直没舍得添砖加瓦,主要是每次想写点东西的时候,随便搜一搜发现都比我总结的都要好,甚感尴尬,但是总是要开始的,所以这就是我的第一篇博客,也绝不会是最后一篇,废话不多说,直接入正题) ...
- AnimatedModal.js – CSS3 全屏模态窗口
AnimatedModal.js 是一个用来创建一个全屏模态窗口的 jQuery 插件,基于 CSS3 过渡实现.您可以利用 Animate.css 中的转换或自行创建自己的过渡效果.支持 Firef ...
- IE全屏浏览代码
以前做过一个网络版的商场导购触摸屏系统,用ASP写的,就是要在运行的时候全屏浏览而不能出现标题栏.工具栏.状态栏等.解决方法是用JS弹出全屏窗口,建立html文件,代码如下: <script l ...
- Android开发中的全屏背景显示方案
引子 不管是Android还是iOS平台中,都可以看到一些应用在启动的时候会先出现一个启动画面(Splash Activity),如QQ.微信等.这个启动画面中往往会将ActionBar和Status ...
随机推荐
- Python 远程开机
用 Python 关机你肯定听过或者实践过,那么用 Python 开机呢?这是一个神奇的方法,教你如何用 Python 来开机. 本文目标 远程开机原理 Python 远程开机代码实现 Python ...
- [Java]LeetCode138. 复制带随机指针的链表 | Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point t ...
- [Swift]LeetCode646. 最长数对链 | Maximum Length of Pair Chain
You are given n pairs of numbers. In every pair, the first number is always smaller than the second ...
- [Swift]LeetCode678. 有效的括号字符串 | Valid Parenthesis String
Given a string containing only three types of characters: '(', ')' and '*', write a function to chec ...
- [Swift]LeetCode1019. 链表中的下一个更大节点 | Next Greater Node In Linked List
We are given a linked list with head as the first node. Let's number the nodes in the list: node_1, ...
- 汉诺塔问题其实很简单 Python 递归经典面试题
话不多说,上代码 1 def hanoi_move(n, source, dest, intermediate): 2 if n >= 1: # 递归出口,只剩一个盘子 3 hanoi_move ...
- Django+Bootstrap+Mysql 搭建个人博客(二)
2.1.博客首页设计 (1)settings.py MEDIA_ROOT = os.path.join(BASE_DIR,'media').replace("//","/ ...
- 前端(各种demo)二:左侧导航栏的折叠和打开(不使用js)基础版和升级版
1.给div设置定位. 复习一下—— css中position有五种属性: static:默认值,没有定位 absolute:绝对定位,相对于父级元素进行定位 relative:相对定位 fixed: ...
- qt程序启动播放动画
qt程序启动播放动画 编辑删除转载 2016-01-20 10:23:11 标签:qt启动动画 1.播放动画 QAxWidget *flash = , ); //QAxWidget使用的是Active ...
- C#版 - 小红书后台开发面试题: 二维数组中的查找
二维数组中的查找 热度指数:24274 时间限制:1秒 空间限制:32768K 本题知识点: 查找 在线提交网址: http://www.nowcoder.com/practice/abc3fe2 ...