一、在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. Android随

    Android的UI也是线程不安全的,如果想要更新应用程序里的UI元素,则必须在主线程中进行,否则就会出现异常.   Android中的异步消息处理机制主要由四个部分组成,Message,Handle ...

  2. 编译MVC解决方案老出现这个问题的原因

    Server Error in '/' Application. The view at '~/Views/Home/Index.cshtml' must derive from WebViewPag ...

  3. 一眼看懂KMP匹配算法

    KMP算法——快速从字符串M(母串)中找出与字符串Z(子串)匹配的子串 例1: 0 1 2 3 4 5 M:a b c a b d Z:  a b d BF算法(最一般的算法,也叫“蛮力算法”): 将 ...

  4. 设置dos窗口的背景色与前景色

    在dos中输入help会列出各种命令,其中有一个color命令可以用来设置当前窗口的前景色和背景色,输入help color会列出使用方法,内容如下: 设置默认的控制台前景和背景颜色. COLOR [ ...

  5. Android Studio打开时提示ADB错误的问题

    如图所示,ADB连接错误,解决办法很简单:打开cmd,定位到sdk文件夹下的platform-tools,然后执行adb kill-server回车:再执行adb start-server即可

  6. Java中main函数只能调用同类中的静态方法?

    如果想调用本类中的非静态方法可以这么来写: public class TT{ public static void main(String[] args){ TT t = new TT(); t.fu ...

  7. POJ 题目3661 Running(区间DP)

    Running Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5652   Accepted: 2128 Descripti ...

  8. 生成模型(Generative)和判别模型(Discriminative)

    生成模型(Generative)和判别模型(Discriminative) 引言    最近看文章<A survey of appearance models in visual object ...

  9. It will affect staff as well.

    Premier Foods has reduced its number of suppliers dramatically in the last 12 months. In 2013 it mad ...

  10. 阿伦学习html5 之 Local Storage (本地储存)

    一.浏览器存储的发展历程 本地存储解决方案很多,比如Flash SharedObject.Google Gears.Cookie.DOM Storage.User Data.window.name.S ...