dialog使用系统自带的有时候不是很美观,就想要自己来设计一个dialog界面,以下就是可以设计的dialog界面:

public class CustomDialog extends Dialog {
int layoutRes;//
Context context;
public CustomDialog(Context context) {
super(context);
this.context = context;
} public CustomDialog(Context context,int resLayout){
super(context);
this.context = context;
this.layoutRes = resLayout;
}
/**
*
* @param context
* @param theme
* @param resLayout
*/
public CustomDialog(Context context, int theme,int resLayout){
super(context, theme);
this.context = context;
this.layoutRes = resLayout;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(layoutRes);
}
}

使用的时候直接实例化,添加布局文件就可以了

CustomDialog dialog=new CustomDialog(this, R.style.customDialog, R.layout.customdialog);

在value/styles.xml中添加dialog的属性

<style name="customDialog" parent="@android:Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>

接下来就可以直接对其像以前的dialog一样操作了。

android自定义dialog布局的更多相关文章

  1. Android自定义 Dialog 对话框

    Android自定义Dialoghttp://www.cnblogs.com/and_he/archive/2011/09/16/2178716.html Android使用自定义AlertDialo ...

  2. Android自定义Dialog及其布局

     实际项目开发中默认的Dialog样式无法满足需求,需要自定义Dialog及其布局,并响应布局中控件的事件. 上效果图: 自定义Dialog,LogoutDialog: 要将自定义布局传入构造函数中, ...

  3. Android—自定义Dialog

    在 Android 日常的开发中,Dialog 使用是比较广泛的.无论是提示一个提示语,还是确认信息,还是有一定交互的(弹出验证码,输入账号密码登录等等)对话框. 而我们去看一下原生的对话框,虽然随着 ...

  4. Android自定义Dialog(美化界面)

    前言:在做项目的时候,发现dialog界面太丑陋,从csdn上下载了一份自定义dialog的源码,在他的基础上对界面进行美化...有需要的朋友可以直接拿走 效果图如下: 主要代码: /** * 自定义 ...

  5. android 自定义Dialog背景透明及显示位置设置

    先贴一下显示效果图,仅作参考: 代码如下: 1.自定义Dialog public class SelectDialog extends AlertDialog{ public SelectDialog ...

  6. Android自定义Dialog

    Android开发过程中,常常会遇到一些需求场景——在界面上弹出一个弹框,对用户进行提醒并让用户进行某些选择性的操作, 如退出登录时的弹窗,让用户选择“退出”还是“取消”等操作. Android系统提 ...

  7. 自定义Dialog布局的弹窗功能的简单实现

    package com.loaderman.dialogdemo; import android.os.Bundle; import android.support.v7.app.AlertDialo ...

  8. Android 自定义Dialog类,并在Activity中实现按钮监听。

      实际开发中,经常会用到Dialog,比如退出时候会弹出是否退出,或者还有一些编辑框也会用Dialog实现,效果图如下: 开发中遇到的问题无非在于如果在Activity中监听这个Dialog中实现的 ...

  9. android 自定义Dialog去除黑色边框

    在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法. 首先在values/styles定义自定义样式: <style name="MyDial ...

随机推荐

  1. PHP array_count_values()

    定义和用法 array_count_values() 函数用于统计数组中所有值出现的次数. 本函数返回一个数组,其元素的键(索引)是原数组的值,元素的值是该值在原数组中出现的次数. 语法 array_ ...

  2. Gulp帮你自己主动搞定coffee和scss的compile

    今天继续说说gulp的watch,能够自己主动搞定非常多事情.不用每次都去敲命令了! 上次说到用gulp能够非常方便的进行css,js,html的压缩.而且能够对coffee和scss进行编译. cs ...

  3. [ACM] POJ 1942 Paths on a Grid (组合)

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21297   Accepted: 5212 ...

  4. bzoj 4025 二分图 分治+并查集/LCT

    bzoj 4025 二分图 [题目大意] 有n个点m条边,边会在start时刻出现在end时刻消失,求对于每一段时间,该图是不是一个二分图. 判断二分图的一个简单的方法:是否存在奇环 若存在奇环,就不 ...

  5. 0.0.0.0 IPAddress.Any 【】127.0.0.1 IPAddress.Loopback 【】localhost

    0.0.0.0  IPAddress.Any https://msdn.microsoft.com/en-us/library/system.net.ipaddress.any(v=vs.110).a ...

  6. What is the difference between task and thread?

    http://stackoverflow.com/questions/4130194/what-is-the-difference-between-task-and-thread 回答一: A tas ...

  7. Codeforces--615B--Longtail Hedgehog(贪心模拟)

     B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input stan ...

  8. 杂项-Java:JDBC

    ylbtech-杂项-Java:JDBC JDBC(Java DataBase Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访 ...

  9. Human Gene Functions(dp)

    http://poj.org/problem?id=1080 #include <stdio.h> #include <stdlib.h> #include <strin ...

  10. php文件,文件夹

    例子代码:<?php$f='/www/htdocs/index.html';$path_parts = pathinfo($f);echo $path_parts['dirname'], &qu ...