创建如下自定义对话框:

JAVA代码

LayoutInflater li = LayoutInflater.from(TagActivity. this);  //NOTE
final View TestView = li.inflate(R.layout.tag_dialog, null);

dialog = 
new Dialog(TagActivity.
this, R.style.dialog);

dialog.setContentView(TestView);

dialog.setCancelable(
true);

dialog.show();

R.layout.tag_dialog如下

<?xml version=
"1.0"
 encoding=
"utf-8"
?>


<LinearLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
 android:layout_width=
"match_parent"
 android:layout_height=
"match_parent"
 android:orientation=
"vertical"
>

  
<LinearLayout android:layout_height=
"wrap_content"
 android:layout_width=
"fill_parent"
>

    
<TextView android:id=
"@+id/title"
 android:layout_height=
"wrap_content"
 android:layout_width=
"fill_parent"
 android:gravity=
"center"
 android:textColor=
"@color/white"
 android:paddingTop=
"15dp"
></TextView>

  
</LinearLayout>

  
<LinearLayout android:layout_width=
"200dp"
 android:layout_height=
"200dp"
 android:orientation=
"vertical"
 android:paddingLeft=
"10dp"
 android:paddingRight=
"10dp"
 android:paddingTop=
"10dp"
>

    
<EditText android:id=
"@+id/name"
 android:layout_width=
"fill_parent"
 android:layout_height=
"wrap_content"
 android:background=
"@color/transparent"
 android:textColor=
"@color/white"
 android:hint=
"输入消息内容"
 android:textColorHint=
"@color/white"
></EditText>

  
</LinearLayout>

  
<LinearLayout android:layout_width=
"fill_parent"
 android:layout_height=
"wrap_content"
 android:orientation=
"horizontal"
 android:layout_marginBottom=
"10dp"
>

    
<RelativeLayout android:layout_width=
"fill_parent"
 android:layout_height=
"wrap_content"
 android:layout_weight=
"1"
>

      
<ImageButton android:id=
"@+id/sure"
 android:layout_width=
"wrap_content"
 android:layout_height=
"wrap_content"
 android:src=
"@drawable/sure"
 android:background=
"@drawable/btn_click_background"
 android:layout_centerHorizontal=
"true"
></ImageButton>

    
</RelativeLayout>

    
<RelativeLayout android:layout_width=
"fill_parent"
 android:layout_height=
"wrap_content"
 android:layout_weight=
"1"
>

      
<ImageButton android:id=
"@+id/cancel"
 android:layout_width=
"wrap_content"
 android:layout_height=
"wrap_content"
 android:src=
"@drawable/cancel"
 android:background=
"@drawable/btn_click_background"
 android:layout_centerHorizontal=
"true"
></ImageButton>

    
</RelativeLayout>

  
</LinearLayout>


</LinearLayout>

R.style.dialog文件如下

<!-- 下面是对话框对应的style -->


<style name=
"dialog"
 parent=
"@android:style/Theme.Dialog"
>

  
<item name=
"android:windowFrame"
>@null
</item>

  
<item name=
"android:windowIsFloating"
>true
</item>

  
<item name=
"android:windowIsTranslucent"
>true
</item>

  
<item name=
"android:windowNoTitle"
>true
</item>

  
<!--<item name="android:background">@android:color/transparent</item>-->

  
<item name=
"android:background"
>@android:color
/transparent
</item>

  
<item name=
"android:windowBackground"
>@drawable
/dialog_bg
</item>

  
<item name=
"android:backgroundDimEnabled"
>true
</item>

  
<item name=
"android:backgroundDimAmount"
>0.6
</item>

  
<item name=
"android:windowFullscreen"
>true
</item>


</style>

android创建自定义对话框的更多相关文章

  1. Android—关于自定义对话框的工具类

    开发中有很多地方会用到自定义对话框,为了避免不必要的城府代码,在此总结出一个工具类. 弹出对话框的地方很多,但是都大同小异,不同无非就是提示内容或者图片不同,下面这个类是将提示内容和图片放到了自定义函 ...

  2. Android创建自定义dialog方法详解-样式去掉阴影效果

    在自定义组件时,从已有组件源码中会很大收获.就拿progressDialog来说     间接父类是dialog,想了解dialog继承结构可以去百度,或者    从构造器来说ProgressDial ...

  3. 2.5.3 使用alertDialog创建自定义对话框

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout ...

  4. Android创建自定义Application

    开发目的 创建一个自定义的MainApplication继承Application. 读取AndroidManifest.xml文件中Application节点的META-DATA数据.此处以ApiK ...

  5. Android 创建自定义布局

    我们所有的控件都是继承至View类的,而所有的布局都是继承至ViewGroup的,所以我们也可以继承某个view类来实现我们自己的布局或者控件. 引入布局 我们新建一个title.xml的layout ...

  6. Android创建自定义的布局和控件

    Android的自带布局有framelayout.linerlayout.relativelayout,外加两个百分比布局,但是这些无法灵活的满足我们的需要,所以我们要自己自定义并引入自己的布局.首先 ...

  7. Android 创建自定义 View 的属性 (attrs) 时需要注意的问题

    自定义 View 的属性并不难,可以参照官方的文档 https://developer.android.com/training/custom-views/create-view.html 但是需要注 ...

  8. Android自定义组件系列【13】——Android自定义对话框如此简单

    在我们的日常项目中很多地方会用到对话框,但是Android系统为我们提供的对话框样子和我们精心设计的界面很不协调,在这种情况下我们想很自由的定义对话框,或者有的时候我们的对话框是一个图片,没有标题和按 ...

  9. Android Studio常见对话框(普通对话框、单选对话框、多选对话框、进度条对话框、消息对话框、自定义对话框)

    Android Studio常见对话框(普通对话框.单选对话框.多选对话框.进度条对话框.消息对话框.自定义对话框) 1.普通对话框 2.单选对话框 3.多选对话框 4.进度条对话框 5.消息对话框 ...

随机推荐

  1. Cloud Foundry中通用service的集成

    目前,CloudFoundry已经集成了很多第三方的中间件服务,并且提供了用户添加自定义服务的接口.随着Cloud Foundry的发展,开发者势必会将更多的服务集成进Cloud Foundry,以供 ...

  2. Maven-1:下载&安装

    (一)下载 下载网址:http://maven.apache.org/download.cgi 版本:3.0.5 (二)安装 1.解压至目录:F:\Kevin\software\apache-mave ...

  3. go之匿名字段

    struct,定义的时候是字段名与其类型一一对应,实际上Go支持只提供类型,而不写字段名的方式,也就是匿名字段,也称为嵌入字段. 当匿名字段是一个struct的时候,那么这个struct所拥有的全部字 ...

  4. 所有CN_消息的说明

    Notification Message Corresponding WindowsConstant Message Description cn_CharToItem wm_CharToItem T ...

  5. TCP连接的建立(二)

    被动打开 SYN cookies TCP协议开辟了一个比較大的内存空间请求连接队列来存储连接请求块,当SYN请求不断添加,请求连接数目到达上限时,会致使系统丢弃SYN连接请求.SYN cookies技 ...

  6. MySQLdb的安装与使用

    一.安装 安装已编译版本号(此方法简便快捷): http://www.codegood.com/downloads 依据自己系统下载,双击安装,搞定 然后import MySQLdb.查看是否成功 我 ...

  7. Threejs 的场景查看 - 几个交互事件库助你方便查看场景

    Threejs 的场景查看 - 几个交互事件库助你方便查看场景 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致&q ...

  8. 正确理解HTML,XHTML页面的头部doctype定义

    摘自http://www.west263.com/info/html/wangyezhizuo/css/20080225/42390.html 当我们制作页面的时候,总会在它的源代码头部看到一串声明, ...

  9. hdu3068之manacher算法+详解

    最长回文 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  10. 开发测试时给 Kafka 发消息的 UI 发送器――Mikasa

    开发测试时给 Kafka 发消息的 UI 发送器――Mikasa 说来话长,自从入了花瓣,整个人就掉进连环坑了. 后端元数据采集是用 Storm 来走拓扑流程的,又因为 @Zola 不是很喜欢 Jav ...