Dialog 自定义使用1

一: 布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:background="@drawable/dialog_bg">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dip"
android:paddingTop="10dip">
<ImageView
android:id="@+id/dialog_title_image"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dialog_title_image"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_centerInParent="true"
android:text="Title" // 标题
android:layout_toRightOf="@id/dialog_title_image"
android:textColor="#000000"
android:textSize="30sp"/> </RelativeLayout>
<TextView
android:layout_width="fill_parent" //横线
android:layout_height="1dip"
android:background="@drawable/lins"
android:layout_marginTop="5dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a custom dialog" //正文
android:textColor="#000000"
android:layout_marginTop="10dip"
android:layout_marginLeft="30dip"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dip"
android:gravity="bottom|center_horizontal"
android:paddingBottom="10dip">
<Button
android:id="@+id/dialog_button_cancel"
android:layout_alignParentLeft="true"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="确定"/>
<Button
android:id="@+id/dialog_button_ok"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/dialog_button_cancel"
android:layout_marginLeft="35dip"
android:text="取消"/>
</RelativeLayout>
</LinearLayout>
1 ,第一步: 样式style.xml代码
<?xml version="1.0" encoding="utf-8"?>
<resources>//
<style name="Mydialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item><!--边框-->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
<item name="android:windowIsTranslucent">false</item><!--半透明-->
<item name="android:windowNoTitle">true</item><!--无标题-->
<item name="android:windowBackground">@color/transparent</item><!--背景透明-->
<item name="android:backgroundDimEnabled">false</item><!--模糊-->
<item name="android:layoutAnimation">@null</item> //dialog弹出时没有动画 </style>
</resources>
自定义的dialog :
public class MyDialog extends Dialog {
Context context;
public MyDialog(Context context) {
super(context);
this.context = context;
}
public MyDialog(Context context, int theme){
super(context, theme);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) { //会先调用这个方法
super.onCreate(savedInstanceState);
this.setContentView(R.layout.dialog);
}
}
第二步 :使用的时候
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//初始化一个自定义的Dialog
Dialog dialog = new MyDialog(MyDialogActivity.this,
R.style.MyDialog); //样式
dialog.show();
}
});
Dialog 自定义使用1的更多相关文章
- 通用的Dialog自定义dialog
图样:
- Android开发:使用DialogFragment实现dialog自定义布局
使用DialogFragment实现dialog的自定义布局最大的好处是可以更好控制dialog的生命周期. TestFragment的代码: public class TestFragment ex ...
- Dialog 自定义使用2(进度条)
1: 自定义的Dialog 代码: public class IphoneProgersssDialog extends Dialog { private Context context; priv ...
- Animate a custom Dialog,自定义Dialog动画
Inside res/style.xml <style name="AppTheme" parent="android:Theme.Light" /> ...
- Dialog 自定义使用3(回调点击事件)
1 , Dialog布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...
- android 自定义Dialog去除黑色边框
在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法. 首先在values/styles定义自定义样式: <style name="MyDial ...
- jQuery Dialog弹出层对话框插件
Dialog.js的相关注释已经添加,可以按照注释,进行相关样式的修改,适用于自定义的各个系统! dialog.js /** * jQuery的Dialog插件. * * @param object ...
- Android学习笔记-Dialog详解
1.对话框的使用 1.1AlertDialog的显示 简单对话框以及监听的设置:重点掌握三个按钮(也就是三上单词): PositiveButton(确认按钮);NeutralButton(忽略按钮) ...
- android dialog圆角显示及解决出现的黑色棱角.(友情提示)
http://blog.csdn.net/jj120522/article/details/7871289 最近在开发一个天气预报的app,看到一个比较不错友情提示,如下: ...
随机推荐
- 期刊搜索问题——SCI、EI、IEEE和中文期刊
1.SCI.EI收录是什么意思? SCI和EI都是收录,并不是实体的期刊出版社,相当于具有高品质期刊出版社的合体(或统充),隔一段时间(几年或者几个月)SCI会进行评估,哪些出版社不具有被SCI收录的 ...
- debian下为stm32f429i-discovery编译uboot、linux内核和根文件系统
交叉编译器:arm-uclinuxeabi-2010q1 交叉编译器下载下来后解压,然后将其中bin文件夹路径加入到PATH变量中. 根据<debian下烧写stm32f429I discove ...
- How MapReduce Works(转)
原文地址:http://www.cnblogs.com/ggjucheng/archive/2012/04/23/2465820.html 一.从Map到Reduce MapReduce其实是分治算法 ...
- hiho一下 第四十八周 拓扑排序·二【拓扑排序的应用 + 静态数组 + 拓扑排序算法的时间优化】
题目1 : 拓扑排序·二 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho所在学校的校园网被黑客入侵并投放了病毒.这事在校内BBS上立刻引起了大家的讨论,当 ...
- linux共享库加载
参考自: <<程序员的自我修养--链接.装载与库>> 第八章 Linux共享库的组织 以下截取部分内容 (这本书比较好的讲解了从程序的链接,装载,到运行) 共享库的兼容性 li ...
- Linux上网设置
ifconfig 命令查看网络设置 步骤1.配置/etc/sysconfig/network-scripts/ifcfg-eth0 里的文件.有的是(ifcfg-ens33) 文件 CentOS下的i ...
- 多种方法求java求整数的位数
方法一 private static int getNumLenght(long num){ num = num>0?num:-num; return String.valueOf(num).l ...
- SpringCloud-服务的消费者(rest+ribbon)
SpringCloud-服务的消费者(rest+ribbon) 在微服务架构中,业务都会被拆分成一个独立的服务,服务与服务的通讯是基于http restful的.Spring Cloud有两种服务调用 ...
- STL中流相关的输入输出符和get函数彻底总结:cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
我的总结: [首先:对于流来说,就把流看成一个中转的仓库,对流进行<<运算或>>运算或者get函数的运算都是指,把“流”中的数据“运送”到“内存变量”中去,还是把内存变量中的数 ...
- electron—Chromium有酒,Node有肉
谷歌V8引擎的出现,Node.js的诞生注定要把开发模式“搅乱”. 基于云应用,服务化,定制化的应用需求不断增加后使得传统的winform开发空间越来越小,而原来做前端的空间越来越大,Node.js ...