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 ...
随机推荐
- [Swift]注册并购买加入Apple开发者计划。提示: “你的支付授权失败。请核对你的信息并重试,或尝试其他支付方式。请联系你的银行”
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- 软件需求规范说明 (Software Requirements Specification, 简称SRS)
GB/T 9385-2008 笔记 为了形成确定和完备的规格说明, 我们需要明确 软件的顾客希望得到什么; 软件的供方理解用户想要什么; 4.2 SRS的基本性质 SRS是对在具体环境中执行确定功能的 ...
- WPF下DataGrid的简单应用
Dim dt As New DataTable() '------------------- dt.Columns.Add(New DataColumn("名称")) dt.Col ...
- JavaScript全局函数
JavaScript 中包含以下 7 个全局函数,用于完成一些常用的功能(以后的章节中可能会用到):escape( ).eval_r( ).isFinite( ).isNaN( ).parseFloa ...
- P3805 【模版】manacher算法
题目描述 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 字符串长度为n 输入输出格式 输入格式: 一行小写英文字符a,b,c...y,z组成的字符串S 输出格 ...
- Git Learning Part II - Working locally
file status life circle basic: modified: Examples: untracked: unmodified: modified: Git branching ...
- 二分图的最大独立集 最大匹配解题 Hopcroft-Karp算法
二分图模型中的最大独立集问题:在二分图G=(X,Y;E)中求取最小的顶点集V* ⊂ {X,Y},使得边 V*任意两点之间没有边相连. 公式: 最大独立集顶点个数 = 总的顶点数(|X|+|Y|)- 最 ...
- Vmware安装Linux系统的vmware-tools
我们应对都用vmware虚拟机,如果虚拟机是windows系统,每次虚拟机下方提示安装vmware-tools时,我们只需要点击安装即可. 但如果虚拟机安装的是linux系统的时候,发现就没一样了. ...
- 三维重建:QT+OpenNI+Kinect图像校正
后记: 当时能不放弃这个方向是因为这里面涉及了一种很有效的三位场景存储方式,可能给出除图元建模之外的一种三维场景描述方式.这和Flash与位图的对比一样,基于图元的flash始终抵不过基于点描述的位图 ...
- win 7环境下java环境变量的配置
http://www.cnblogs.com/zhj5chengfeng/archive/2013/01/01/2841253.html %Java_Home%\bin;%Java_Home%\jre ...