Android培训教程-自定义对话框Dialog的几种方式

更新时间:2024-05-16 14:07:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

http://www.moliying.com

接下来我就以一个简单风格的自定义Dialog来讲讲自定义dialog的一般步骤和原理

第一步: 给Dialog设置一个风格主题(基本都是用这个主题)无边框全透明背景

第二步:给自定的Dialog设置自定义的 xml界面,我这里只是示范,你可以使用单选,多选,3个按钮,4个按钮等等,格式各样的自定义XML,我这里就定义了 标题title,信息message,还有一个确定按钮和取消按钮,如下:

磨砺营IT教育版权所有

http://www.moliying.com

android:layout_width=\ android:layout_height=\ android:background=\

android:layout_width=\ android:layout_height=\ android:layout_centerInParent=\

android:background=\ android:orientation=\

android:id=\

android:layout_width=\ android:layout_height=\ android:layout_gravity=\ android:layout_margin=\ android:gravity=\ android:text=\消息提示\ android:textColor=\ android:textSize=\

磨砺营IT教育版权所有

http://www.moliying.com

android:id=\

android:layout_width=\ android:layout_height=\ android:layout_marginLeft=\ android:layout_marginRight=\ android:text=\提示消息\

android:layout_width=\ android:layout_height=\ android:layout_marginTop=\ android:background=\

android:layout_width=\ android:layout_height=\ android:orientation=\

Top