AlertDialog自己定义View的使用方法+怎样改变弹出框的大小
android系统定义了弹出框,支持我们自己定义布局:
public AlertDialog getEditCustomDialog() {
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.custom_message_rename, null);
AlertDialog.Builder builder = new AlertDialog.Builder(AnimationTest.this);
builder.setView(view);
builder.setTitle("A New Version is Available");
return builder.create();
}
<? 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="wrap_content"
android:orientation="vertical" > <EditText
android:id="@+id/rc_document_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:imeOptions="flagNoEnterAction"
android:inputType="textNoSuggestions"
android:maxLines="5"
android:textColor="#000000"
android:textSize="@dimen/font_size_medium" /> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="? android:attr/dividerHorizontal" /> <LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:measureWithLargestChild="true"
android:orientation="horizontal"
android:padding="0dp" > <Button
android:id="@+id/cancelBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:text="Cancel" /> <View
android:id="@+id/postCancelBtnDivider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?android:attr/dividerHorizontal" /> <Button
android:id="@+id/okBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="? android:attr/selectableItemBackground"
android:text="OK" />
</LinearLayout> </LinearLayout>
效果图是:
另一种常见的样式是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="60dp" > <TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="60dp"
android:layout_marginLeft="25dp"
android:text="@string/upgrade_content"
android:textColor="#000000"
android:textSize="22sp" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@id/content"
android:orientation="horizontal" > <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:text="@string/remind_me"
android:textColor="#000000"
android:textSize="14sp" />
</LinearLayout> </RelativeLayout>
效果图是:
假设想改变Dialog的大小能够这样写:
<span style="white-space:pre"> </span>AlertDialog dialog = getCustomDialog();
dialog.show(); //一定得在show完dialog后来set属性
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.width = AnimationTest.this.getResources().getDimensionPixelSize(R.dimen.dialog_width);
lp.height = AnimationTest.this.getResources().getDimensionPixelSize(R.dimen.dialog_height);
dialog.getWindow().setAttributes(lp);
AlertDialog自己定义View的使用方法+怎样改变弹出框的大小的更多相关文章
- VUX的使用方法(以弹出框为例)
一.安装 cnpm install vux --save cnpm install vux-loader --save-dev 二.配置 const vuxLoader = require('vux- ...
- Android自己定义View的实现方法
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17357967 不知不觉中,带你一步步深入了解View系列的文章已经写到第四篇了.回 ...
- 练习PopupWindow弹出框之实现界面加载的时候显示弹出框到指定的view下面--两种延迟方法
今天在练习PopupWindow弹出框的时候,打算在界面加载的时候将弹出框展现出来并显示在指定的view下面. 初步方法是直接在OnResume方法里面直接执行showPopupWindows方法. ...
- android 自定义弹出框AlertDialog ,很炫的哦
于是就小小的模仿了下自己写了这个这样的效果,主要代码如下:dlg = new AlertDialog.Builder(context).create();dlg.show();dlg.getWin ...
- 将angular-ui-bootstrap的弹出框定义成一个服务的实践
定义一个弹出框的服务:alert_boxdefiine(["app"],function(mainapp){ mainapp.controller('ModalInstanceCt ...
- Android--自定义弹出框-自定义dialog
项目要用到弹出框,还要和苹果的样式一样(Android真是没地位),所以就自己定义了一个,不是很像(主要是没图),但是也还可以. 废话不多说了,直接上代码 1.先看布局文件 <?xml vers ...
- angular-ui-bootstrap的弹出框定义成一个服务的实践(二)
定义一个弹出框的服务:alert_box defiine(["app"],function(mainapp){ mainapp.controller('ModalInstanceC ...
- layer弹出框插件参数及方法介绍
layerui下载:http://www.layui.com 更多参数请阅读开发文档:http://www.layui.com/doc/modules/layer.html Layui 是一款采用自身 ...
- UniGui的信息弹出框MessageDlg自定义标题的方法(使用JS动态本地化文本)
UniGui的信息弹出框MessageDlg的原型定义如下: procedure MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons ...
随机推荐
- 【转】IOS中Json解析的四种方法
原文网址:http://blog.csdn.net/enuola/article/details/7903632 作为一种轻量级的数据交换格式,json正在逐步取代xml,成为网络数据的通用格式. 有 ...
- Quartz实例:quartz定时任务代码示例
转自:http://www.blogchong.com/post/96.html quartz定时任务调度框架,使用实例. Job类://即实际调度任务实现 . package net.csdn.ed ...
- xss 记录cookie
<p> <img src="http://act.ci123.com/global/ueditor_new/php/upload/98591403834900.jpg&qu ...
- 配置Windows群集
故障转移群集 l 一个群集支持8个节点,(64位操作系统支持16个节点) l 可以使用故障转移群集的服务:SQL Server(数据库), Exchange(邮件),文件和打印服务,DHCP服务等 ...
- BZOJ-3732 Network 图论 最小生成树 倍增
题面 题意:给你N个点,M条边的无向图 (N<=15000,M<=30000)第j条边的长度为 dj (1<=dj<=1e9),然后K个询问 (1<=K<=2000 ...
- ROS-tutorials-launch-查看日志
前言:launch文件的作用是一次可以启动多个节点. 1.新建launch文件 在chapter2_tutorials包下新建launch文件夹,并在launch文件夹下新建chapter2.laun ...
- php 微信支付 回调通知不停的坑
微信支付已完工,最后有点小问题就是微信的回调会重复9次 第一步: $return = "success"; echo $return; 不管用 第二步: $return = &qu ...
- Solr.NET快速入门(三)【高亮显示】
此功能会"高亮显示"匹配查询的字词(通常使用标记),包括匹配字词周围的文字片段. 要启用高亮显示,请包括HighlightingParameters QueryOptions对象, ...
- html行级元素和块级元素以及css转换
之前有说过html的标签是有语义的,当然也就有一些默认的样式,比如标题有h1···h6,他们的字体由大至小一次递减,字体比一般字体要加粗. 这样也就有了行级元素和块级元素,下面来看看什么是行级元素什么 ...
- Boost1.67编译+CMake Generate时遇到的一个错误
下载的一个库编译时依赖boost,记录一下boost的编译: 下载源码 vs命令行里cd到根目录,运行bootstrap.bat,发现多了几个文件{b2.exe.bjam.exe.project-co ...