<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"><ImageViewandroid:id="@+id/titleImage"android:layout_height="wrap_content"android:layout_width="wrap_content"android:src="@drawable/worning"android:layout_marginBottom="-25dp"android:layout_centerHorizontal="true"android:visibility="invisible" /><RelativeLayoutandroid:layout_height="wrap_content"android:layout_width="match_parent"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_below="@id/titleImage"android:background="@drawable/dialog_background"><RelativeLayoutandroid:id="@+id/dialog_tip"android:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_marginTop="30dp"android:layout_centerHorizontal="true"><Viewandroid:id="@+id/dialog_line_one"android:layout_height="0.5dp"android:layout_width="70dp"android:layout_marginLeft="0dp"android:background="#AAA"android:layout_centerVertical="true"android:layout_marginTop="45dp"/><TextViewandroid:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_marginLeft="12dp"android:layout_marginTop="12dp"android:layout_toRightOf="@id/dialog_line_one"android:id="@+id/dialog_title"android:text="温馨提示"android:textColor="#AAA"android:textSize="20sp" /><Viewandroid:id="@+id/dialog_line_two"android:layout_height="0.5dp"android:layout_width="70dp"android:layout_marginLeft="20dp"android:layout_toRightOf="@id/dialog_title"android:background="#AAA"android:layout_centerVertical="true"android:layout_marginTop="45dp"/></RelativeLayout><TextViewandroid:id="@+id/dialog_content"android:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:text="您的手机存储控件不足\n请清理空间后重试"android:gravity="center_horizontal"android:textSize="20sp"android:textColorHighlight="#2151E0"android:layout_centerHorizontal="true"android:layout_below="@id/dialog_tip"/><LinearLayoutandroid:id="@+id/dialog_btns"android:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_centerHorizontal="true"android:layout_below="@id/dialog_content"><Buttonandroid:layout_weight="1"android:id="@+id/dialog_btn_positive"android:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_marginTop="30dp"android:text="确定"android:textColor="#2cBF5F"android:background="@drawable/btn_green_back"/><Buttonandroid:layout_weight="1"android:id="@+id/dialog_btn_nagtive"android:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_centerHorizontal="true"android:layout_toRightOf="@id/dialog_btn_positive"android:layout_marginTop="30dp"android:layout_marginLeft="20dp"android:text="取消"android:textColor="#2cBF5F"android:background="@drawable/btn_green_back"android:visibility="gone"/></LinearLayout><Viewandroid:layout_height="30dp"android:layout_width="match_parent"android:layout_below="@id/dialog_btns"/></RelativeLayout><ImageViewandroid:layout_height="wrap_content"android:layout_width="wrap_content"android:src="@drawable/worning"android:layout_marginBottom="-25dp"android:layout_centerHorizontal="true" />
</RelativeLayout>

  

弹窗实现方式大概有三种,这是使用系统的弹窗来实现的。标志性的方法是setview()

final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(LoginActivity.this);final AlertDialog alertDialog = dialogBuilder.create();LayoutInflater inflater=LayoutInflater.from(LoginActivity.this);View view = inflater.inflate(R.layout.popup, null);

TextView tv_content = (TextView) view.findViewById(R.id.dialog_content);tv_content.setText("确定要退出吗?");

TextView tv_title= (TextView) view.findViewById(R.id.dialog_title);tv_title.setText("温馨提示");

Button dialog_btn_positive= (Button) view.findViewById(R.id.dialog_btn_positive);dialog_btn_positive.setText("好");dialog_btn_positive.setOnClickListener(new View.OnClickListener() {   @Override   public void onClick(View view) {      alertDialog.dismiss();      finish();   }});

Button dialog_btn_nagtive= (Button) view.findViewById(R.id.dialog_btn_nagtive);dialog_btn_nagtive.setText("取消");dialog_btn_nagtive.setVisibility(View.VISIBLE);dialog_btn_nagtive.setOnClickListener(new View.OnClickListener() {   @Override   public void onClick(View view) {      alertDialog.dismiss();   }});

alertDialog.show();alertDialog.setContentView(view);

---11.12日,在魅族手机MX4以上,有人说会感叹号后面有个矩形的背景色----说下解决办法 :很简单 ,至修改一个地方就可以
new AlertDialog.Builder(new ContextThemeWrapper(MyInfoActivity.this,R.style.WinDialog));
<style name="WinDialog" parent="@android:style/Theme.Dialog">    <item name="android:windowFrame">@null</item>    <item name="android:windowIsFloating">true</item>    <item name="android:windowIsTranslucent">false</item>    <item name="android:windowNoTitle">true</item>    <item name="android:windowBackground">@android:color/transparent</item>    <item name="android:background">@android:color/transparent</item></style>

转载于:https://www.cnblogs.com/qianyukun/p/4950152.html

alertdialog.builder 自定义弹窗相关推荐

  1. 自定义AlertDialog.Builder对话框

    在工作中,原生态的AlertDialog已经远远不能满足我们工作的需求,这时候,就需要使用自定义的AlertDialog.Builder: 在自定义之前,我们先了解下, **原生态的AlertDial ...

  2. android builder布局方式,android – AlertDialog.Builder与自定义布局和EditText;无法访问视图...

    我试图用EditText对象创建一个警报对话框.我需要以编程方式设置EditText的初始文本.这是我有的. AlertDialog.Builder dialogBuilder = new Alert ...

  3. Android--万能自定义弹窗

    使用的是AlertDialog 自定义弹窗呢,就是一个界面放在了AlertDialog容器弹框上. 第一步:写好你的界面 (在layout下创建system_admin_psw_alert_dialo ...

  4. AlertDialog和自定义对话框

    ***AlertDialog *常用方法: setTitle():设置对话框的标题 setIcon():设置对话框图标 setMessage():设置对话框要传达的具体信息 setCancelable ...

  5. flutter自定义弹窗

    今天接到这样一个需求,需要自定义弹窗,所以就有了如下的代码: 通过分析,一切皆widget 所以可以这样实现: import 'package:flutter/cupertino.dart'; imp ...

  6. Android 中文 API ——对话框 AlertDialog.Builder

    2019独角兽企业重金招聘Python工程师标准>>> 刚开始接触android的时候,我在做一个自定义对话框的时候,也是通过继承的方式来实现,后来随着对文档了解的深入,发现了and ...

  7. Android详细的对话框AlertDialog.Builder使用方法

    我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的朋友都会知道,大部分的平台都只提供了几个最简单的实现,如果我们想实现自己特定需求的对话框,大家可能首先会想到,通过继承等 ...

  8. android AlertDialog.Builder

    AlertDialog的构造方法全部是Protected的,所以不能直接通过new一个AlertDialog来创建出一个AlertDialog. 要创建一个AlertDialog,就要用到AlertD ...

  9. android dialog 自定义布局,如何设置AlertDialog的自定义布局?

    调用我的对话框:alertDialog = showInfoDialog(message = "$wrongPasscodeMessage\n$retryMessage") 方法如 ...

最新文章

  1. 在windows8 上安装framework 3.5
  2. pom.xml中的dependencyManagement
  3. React-生命周期杂记
  4. MATLAB在人工智能中的应用案例:以MATLAB的方式玩转自动驾驶(附部分代码)
  5. Linux服务器重启后crs_stat -t 命令无法正常使用以及解决思路
  6. LeetCode 1755. 最接近目标值的子序列和(状态枚举 + 双指针)
  7. linux major头文件_Linux的字符设备
  8. HTML5-Ajax文件上传(转)
  9. POJ 1149 PIGS(最大流)dinic模板注释
  10. KMP算法 C#实现 字符串查找简单实现
  11. 日报系统、周报系统推荐
  12. 大屏导航Linux系统下载,掌讯方案MTK3561大屏导航ROOT固件
  13. LINUX PPP拨号永久在线保障机制
  14. Unity 制作旋转门 推拉门 柜门 抽屉 点击自动开门效果 开关门自动播放音效 (附带编辑器扩展代码)
  15. DVD-Video 解谜 - VOB文件
  16. SOC安全运营中心(一) OSSIM安装
  17. 手机配件实体店好做不_震惊!手机实体店,你不得不防的套路!
  18. Java_输入圆的半径,计算周长及面积
  19. 并联电容器总结与理解
  20. 电驴!最好的客户端,eMule Xtreme Mod ,没有VeryCD我不怕!

热门文章

  1. 进阶学习(3.3) Abstract Factory Pattern 抽象工厂模式
  2. 外贸网络推广浅谈蜘蛛抓取频次的原则跟哪些有关?
  3. python第五单元答案_中国大学MOOC第五单元测试答案_数据结构与算法Python版慕课答案在哪里可以看...
  4. xml 里设置变量_[技巧] ApiPost操作设置
  5. npoi的mvc怎么ajax导出,asp.net mvc利用NPOI导入导出Excel解决方法
  6. python爬取图片教程-推荐|Python 爬虫系列教程一爬取批量百度图片
  7. 在arm linux mini2440上移植ntp服务,RTEMS 4.9.5 在 QEMU MINI2440 上的移植发布啦……
  8. 开发日记-20190915 关键词 汇编语言王爽版 第九章
  9. git svn 一个疯(傻)子的想法
  10. 动态域名作为dga的做法