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,看到一个比较不错友情提示,如下: ...
随机推荐
- shell编程1
shell编程1 一.shell基础正则表达式 1.正则表达式和通配符 正则表达式是用来在文件中匹配符合条件的字符串,正则式包含匹配.(grep awk sed) 通配符是用来匹配符合条件的文件名,通 ...
- Spring声明式事务管理与配置介绍
转至:http://java.9sssd.com/javafw/art/1215 [摘要]本文介绍Spring声明式事务管理与配置,包括Spring声明式事务配置的五种方式.事务的传播属性(Propa ...
- 2018年长沙理工大学第十三届程序设计竞赛 C 取手机 【概率】
链接:https://www.nowcoder.com/acm/contest/96/C 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
- 网络编程概述和IP地址的获取方法
java网络通信概述 一.网络通信步骤: 主机1 主机2 QQ-------QQ FEIQ-----FEIQ 1.找到对方IP. 2.找到对方端口号.数据要发送到对方的应用程序上.为了标识这些应用程序 ...
- 【三】MongoDB文档的CURD操作
一.插入文档 使用insert方法插入文档到一个集合中,如果集合不存在创建集合,有以下几种方法: db.collection.insertOne({}):(v3.2 new) #插入一个文档到集合中 ...
- P3160 [CQOI2012]局部极小值
题目 P3160 [CQOI2012]局部极小值 一眼就是状压,接下来就不知道了\(qwq\) 做法 我们能手玩出局部小值最多差不多是\(8,9\)个的样子,\(dp_{i,j}\)为填满\(1~i\ ...
- 算法(Algorithms)第4版 练习 2.2.26
在sort函数创建aux数组: package com.qiusongde; import edu.princeton.cs.algs4.In; import edu.princeton.cs.alg ...
- php一维数组的创建
php一维数组的创建 (1)通过array函数声明数组 使用array 函数定义数组,该函数返回通过所接受接收的参数建立的数组.array 函数使用的格式如下. $arry_name = array( ...
- django1.8.3搭建博客——2 django web 开发指南阅读笔记
一. django框架 1 .http封装web服务的整个过程.由请求(request)和响应(response)两部分组成. 请求的内容为URL (指向文档的路径). 响应主要为正文(body ...
- BEC listen and translation exercise 41
Its advantages are that it can be used for outside activities So my recommendation I'm afraid would ...