创建如下自定义对话框:

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. 与众不同 windows phone (7) - Local Database(本地数据库)

    原文:与众不同 windows phone (7) - Local Database(本地数据库) [索引页][源码下载] 与众不同 windows phone (7) - Local Databas ...

  2. STL之涉及到的算法

    一.非变异算法 是一组不破坏操作数据的模板函数,用来对序列数据进行逐个处理.元素查找.子序列搜索.统计和匹配.非变异算法具有极为广泛的适用性,基本上可应用与各种容器. 1查找容器元素find 它用于查 ...

  3. EndNote是一款着名的参考文献管理软件

    EndNote是一款着名的参考文献管理软件,我们可以通过该软件创建个人参考文献库,此外对公司DCC.法务和专 利部门十分的有用,甚至对我们写SOP 也有些帮忙,并且该软件可以在其中加入文本.图像.表格 ...

  4. Java学习之道:jdk环境变量配置方法

    JDK(Java Development Kit)是整个Java的核心,包含了Java执行环境.Java工具和Java基础类库.JDK作为JAVA开发的环境,无论是做JAVA开发还是做安卓开发,都必须 ...

  5. 解决Andriod使用HttpURLConnection 失败问题

    在Android的Activity中使用HttpURLConnection连接到服务端时抛出异常,Access denied.第一个想到是权限问题.然后就尝试将INTERNET权限加上:在Manife ...

  6. Redis slowlog

    和mongo的slowlog一样,redis中对于操作时间较长(默认为10秒)的命令也会记录下来,不过它将它们保存在redisServer结构中的slowlog这个链表中,新进来的log排在链表头部, ...

  7. Linux pipe功能

    1. 功能说明 pipe(管道建设): 1) 头 #include<unistd.h> 2) 定义函数: int pipe(int filedes[2]); 3) 函数说明: pipe() ...

  8. STM32 + RT Thread OS 学习笔记[四]

    1.  补注 a)      硬件,打通通讯通道 若学习者购买了学习板,通常可以在学习板提供的示例代码中找到LCD的相关驱动代码,基本上,这里的驱动的所有代码都可以从里面找到. 从上面的示意图可见,M ...

  9. 基于DSP的疲劳驾驶检测系统的研究

    原地址:http://www.chinaaet.com/article/index.aspx?id=114534 关键词:疲劳检测DSP亮瞳效应PERCLOS 摘  要: 针对汽车驾驶员疲劳驾驶检测的 ...

  10. [PHP]利用MetaWeblog API实现XMLRPC功能

    [PHP]利用MetaWeblog API实现XMLRPC功能 | OWNSELF [PHP]利用MetaWeblog API实现XMLRPC功能 Windows Live Writer是一款小巧的写 ...