一、在XML中定义好要显示的AlertDialog的布局

二、在代码中创建alertdialog 对象

AlertDialog dialog = new AlertDialog.Builder(this).create();

调用show方法显示

 dialog.show();

三、设置 AlertDialog窗体的大小

dialog.getWindow().setGravity(Gravity.CENTER);

dialog.getWindow().setLayout((int)(width/1.5), LayoutParams.WRAP_CONTENT);

点击输入框时用来显示软键盘
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

显示布局
dialog.getWindow().setContentView(roleAlertLayout);

当单击外层布局时隐藏软键盘

layout.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
InputMethodManager imm = (InputMethodManager)getSystemService(PageRole.this.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(roleEdit.getWindowToken(), 0);
}
});

自定义AlertDialog的样式的更多相关文章

  1. 安卓—自定义 AlertDialog 的样式

    自定义修改安卓弹出框的样式 效果图: 1.在style.xml下添加 <!-- 自定义弹出样式 --> <style name="MyDialogStyle" p ...

  2. AlertDialog.Builder 样式设置

    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDia ...

  3. jQuery Validate 表单验证插件----自定义校验结果样式

    一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW  访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...

  4. Android 自定义RadioButton的样式

    Android 自定义RadioButton的样式 我们知道Android控件里的button,listview可以用xml的样式自定义成自己希望的漂亮样式. 最近用到RadioButton,利用xm ...

  5. ActionBar官方教程(11)自定义ActionBar的样式(含重要的样式属性表及练习示例)

    Styling the Action Bar If you want to implement a visual design that represents your app's brand, th ...

  6. 自定义input file样式

    自定义input file样式:一般都是通过隐藏input,通过定义label来实现.这种做法要注意的是label的for属性要指定input对应的id; <!DOCTYPE html> ...

  7. WPF界面设计技巧(4)—自定义列表项样式

    原文:WPF界面设计技巧(4)-自定义列表项样式 有前面修改按钮样式的基础,我们可以尝试来定制一个即好看又好用的 ListBox ,今天先来讲“好看”部分. 打开 Microsoft Visual S ...

  8. css Cursor:url()自定义鼠标指针样式为图片

    css自定义鼠标指针样式为图片Cursor:url()的使用,今天在项目中,要用到自定义鼠标样式,格式: css:{cursor:url('绝对路径的图片(格式:cur,ico)'),-moz-zoo ...

  9. Android之自定义AlertDialog和PopupWindow实现(仿微信Dialog)

    我们知道,在很多时候,我们都不用Android内置的一些控件,而是自己自定义一些自己想要的控件,这样显得界面更美观. 今天主要是讲自定义AlertDialog和popupWindow的使用,在很多需求 ...

随机推荐

  1. 安装VS 2013遇到的问题,及解决方案

    一.在启动调试时报错 Visual Studio 2013 虽然集成安装了 IIS Express 8.0,但是并未安装 WebMatrix ,第一个问题就是这个原因造成的. 解决方案: 1.下载最新 ...

  2. Java: IO 学习小结

    源: 键盘 System.in 硬盘 FileStream 内存 ArrayStream 目的: 控制台 System.out 硬盘 FileStream 内存 ArrayStream 处理大文件或者 ...

  3. 记一次联想A820t救砖线刷

    因为是看着教程刷的(有大神放出教程,只管伸手拿来就好啦)但是照着教程做的过程中出现了一些问题还是值得注意的,在这里总结一下,给新手提供一点建议 教程比较长,我放到博客的文件中,需要的自己下载一下.或者 ...

  4. Myeclipse——SSH框架搭建

    Struts2.x+Spring3.x+Hibernate3.x 一.首先建立一个Web 工程 二.搭建Struts 右键工程,选择MyEclipse->Add Struts Capabilit ...

  5. JSTL跳出<c:forEach>循环

    <c:forEach items="${consultPager.dataList }" var="consult"> <tr> < ...

  6. Android中数据的传递以及对象序列化

    Android中当两个Activity需要有信息交互的时候,可以使用Intent.具体来说: 发送单一类型数据: 发送方: String data = "Hello SecondActivi ...

  7. http调接口

    private static String doGetResult(String urlStr, Map<String, String> params) throws Exception ...

  8. ASP.NET中Onclick和OnserverClick事件的区别

    对于服务器按钮控件(即<asp:Button>类型的按钮): 服务器响应事件:OnClick 客户端响应属性:OnClientClick 对于html按钮控件(即<input typ ...

  9. C++小项目:directx11图形程序(三):graphicsclass

    这是框架的第三层graphicsclass,这个类才真正可以说是整个程序的框架,因为它组织了后面所有的成员. 代码: graphicsclass.h #pragma once #include< ...

  10. React Native 组件样式测试

    View组件默认样式(注意默认flexDirection:'column') {flexGrow:0,flexShrink:0,flexBasis:'auto',flexDirection:'colu ...