创建如下自定义对话框:

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. C++(MFC)中WebBrowser去除3D边框的方法(实现IDocHostUIHandler接口)

    先说实在的:最终解决办法是实现IDocHostUIHandler接口,在GetHostInfo方法里解决,但“实现接口”意味着QueryInterface.AddRef.Release三个方法必须实现 ...

  2. J2EE开发框架搭建(2) - springmvc4 + spring4 + hibernate4 整合

    1. 打开hqhop-framework-parent项目下的pom.xml文件.加入springmvc4 , spring4 , hibernate4 ,以及数据源druid的依赖包,插件,依赖包版 ...

  3. Cocos2d-X3.0 刨根问底(九)----- 场景切换(TransitionScene)源代码分析

    上一章我们分析了Scene与Layer相关类的源代码,对Cocos2d-x的场景有了初步了解,这章我们来分析一下场景变换TransitionScene源代码. 直接看TransitionScene的定 ...

  4. SVN的项目管理

    基于SVN的项目管理——集中与分散   我们在此处不讨论 GIT 比 SVN 好多少,也不讨论 Maven 和 Gradle 哪个好用,基于现有的开发环境,大多数公司还是采用 SVN + Maven ...

  5. Qt 向word中插入文字(使用QAxWidget和QAxObject)

    pro 文件中要加入 CONFIG += qaxcontainer 2. main.cpp #include <QApplication> #include <QAxWidget&g ...

  6. 简单的Ajax应用实例

    从网页前端输入提示范围内的字符,然后显示从后台返回的结果 <html> <head> <meta http-equiv="content-type" ...

  7. VS2010使用静态编译的qt库

    Qt开发界面很方便,但发布程序就不那么方便了,你的把引用到的dll一起发布才行,要是能静态编译就好了,发布的时候只有一个exe多方便. 虽然以前为了方便,直接安装的qt-windows-opensou ...

  8. Java基础之数组序列化、反序列化 小发现(不知道 是不是有问题)

    结论:  数组,无论是否声明为transient,都是可以序列化.反序列化的. 测试情况如下: 1.两种类型的数组:int .String: 2 声明为transient  或者不做任何修饰:. 3. ...

  9. hdu 1007 最近点对问题(Splay解法)

    为什么要写这个题..经典啊,当然,别以为我用分治做的,不过主要思想还是那神奇的六个点共存(一个h*2h的矩形中最多能放下多少个点使得两两距离不超过h) 其实我是在这里看到的 http://commun ...

  10. PyRedisAdmin v1.0 Beta 发布,Redis 在线管理工具 - 开源中国社区

    PyRedisAdmin v1.0 Beta 发布,Redis 在线管理工具 - 开源中国社区 PyRedisAdmin v1.0 Beta 发布,Redis 在线管理工具