android创建自定义对话框
创建如下自定义对话框:
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创建自定义对话框的更多相关文章
- Android—关于自定义对话框的工具类
开发中有很多地方会用到自定义对话框,为了避免不必要的城府代码,在此总结出一个工具类. 弹出对话框的地方很多,但是都大同小异,不同无非就是提示内容或者图片不同,下面这个类是将提示内容和图片放到了自定义函 ...
- Android创建自定义dialog方法详解-样式去掉阴影效果
在自定义组件时,从已有组件源码中会很大收获.就拿progressDialog来说 间接父类是dialog,想了解dialog继承结构可以去百度,或者 从构造器来说ProgressDial ...
- 2.5.3 使用alertDialog创建自定义对话框
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout ...
- Android创建自定义Application
开发目的 创建一个自定义的MainApplication继承Application. 读取AndroidManifest.xml文件中Application节点的META-DATA数据.此处以ApiK ...
- Android 创建自定义布局
我们所有的控件都是继承至View类的,而所有的布局都是继承至ViewGroup的,所以我们也可以继承某个view类来实现我们自己的布局或者控件. 引入布局 我们新建一个title.xml的layout ...
- Android创建自定义的布局和控件
Android的自带布局有framelayout.linerlayout.relativelayout,外加两个百分比布局,但是这些无法灵活的满足我们的需要,所以我们要自己自定义并引入自己的布局.首先 ...
- Android 创建自定义 View 的属性 (attrs) 时需要注意的问题
自定义 View 的属性并不难,可以参照官方的文档 https://developer.android.com/training/custom-views/create-view.html 但是需要注 ...
- Android自定义组件系列【13】——Android自定义对话框如此简单
在我们的日常项目中很多地方会用到对话框,但是Android系统为我们提供的对话框样子和我们精心设计的界面很不协调,在这种情况下我们想很自由的定义对话框,或者有的时候我们的对话框是一个图片,没有标题和按 ...
- Android Studio常见对话框(普通对话框、单选对话框、多选对话框、进度条对话框、消息对话框、自定义对话框)
Android Studio常见对话框(普通对话框.单选对话框.多选对话框.进度条对话框.消息对话框.自定义对话框) 1.普通对话框 2.单选对话框 3.多选对话框 4.进度条对话框 5.消息对话框 ...
随机推荐
- HDU--杭电--4504--威威猫系列故事——篮球梦--DP
威威猫系列故事——篮球梦 Time Limit: 300/100 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total ...
- java jquery 函数多參数传递
业务需求: 名次 伙伴 业绩 签单 面谈 每日目标 1 文彬 5100 6 10 查看目标 2 马红月 4550 4 6 查看目标 3 王刚 4100 3 9 查看目标 4 郭亚凯 3450 4 ...
- Swift - 使用导航条和导航条控制器来进行页面切换
通过使用导航条(UINavigationBar)与导航条控制器(UINavigationController)可以方便的在主页面和多层子页面之间切换.下面通过一个简单“组件效果演示”的小例子来说明如何 ...
- C文件操作的语言fgets()
谈fgets(..)功能. 原型 char * fgets(char * s, int n,FILE *stream); 參数: s: 字符型指针.指向存 ...
- How to append files to a .tar archive using Apache Commons Compress?(转)
I created a copy of the tar archive and copied to entire content to it. Then I delete the old tar ar ...
- C语言盲点笔记1
寥寥数笔,记录我的C语言盲点笔记,仅仅为以前经历过,亦有误,可交流. 1.int* a和int *a有差别吗? 没有不论什么差别,都表示a是int指针 建议这么写int *a;这样明显一点 理由例如以 ...
- iOS视图控制器之间delegate传值教程
之前在StackOverFlow上看到一篇讲传值(segue传值和delegate传值)的文章,感觉讲的非常清晰,就将delegate部分翻译了一下.有兴趣能够看看. 原文: http://stack ...
- delphi cmd(4个例子都是通过管道取得)
//K8执行DOS并返回结果 function RunDosCommand(Command: string): string; var hReadPipe: THandle; hWritePipe: ...
- mysql 高可用方案MHA介绍
概述 MHA是一位日本MySQL大牛用Perl写的一套MySQL故障切换方案,来保证数据库系统的高可用.在宕机的时间内(通常10—30秒内),完成故障切换,部署MHA,可避免主从一致性问题,节约购买新 ...
- latex命令替换之\newcommand
有时候我们在用latex写文档的时候不想写很长的命令,那么我们自己定义一个新的命令来替换一段代码. 举例如下: \usepackage{booktabs} \usepackage{multirow} ...