先贴一下显示效果图,仅作参考:

代码如下:

1、自定义Dialog


public class SelectDialog extends AlertDialog{

public SelectDialog(Context context, int theme) {
    super(context, theme);
} public SelectDialog(Context context) {
    super(context);
} @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.slt_cnt_type);
}
}

2、布局文件slt_cnt_type.xml代码


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:padding="10dp" android:layout_width="115dp" android:layout_height="wrap_content" android:background="@color/blue">
    <Button android:layout_height="wrap_content" android:background="#00000000" android:layout_width="fill_parent" android:text="全部联系人" android:paddingTop="5dp" android:paddingBottom="5dp" android:paddingLeft="10dp" android:gravity="left|center_vertical" android:id="@+id/btnSltCntAll"></Button>
    <Button android:layout_height="wrap_content" android:background="#00000000" style="@drawable/greenhand_button" android:text="咕咚用户" android:gravity="left|center_vertical" android:paddingBottom="5dp" android:paddingTop="5dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:layout_width="fill_parent" android:id="@+id/btnSltGudongUser"></Button>
    <Button style="@drawable/greenhand_button" android:background="#00000000" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="推荐用户" android:gravity="left|center_vertical" android:paddingTop="5dp" android:paddingBottom="5dp" android:paddingLeft="10dp" android:id="@+id/btnSltRecommend"></Button>
</LinearLayout>

3、颜色color.xml代码

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="transparent">#00000000</color>
</resources>

4、样式style.xml代码


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="dialog" 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><!--模糊-->
    </style>
</resources>

4、显示Dialog


SelectDialog selectDialog = new SelectDialog(this,R.style.dialog);//创建Dialog并设置样式主题
Window win = selectDialog.getWindow();
LayoutParams params = new LayoutParams();
params.x = -80;//设置x坐标
params.y = -60;//设置y坐标
win.setAttributes(params);
selectDialog.setCanceledOnTouchOutside(true);//设置点击Dialog外部任意区域关闭Dialog
selectDialog.show();

以上仅作参考,如有问题,请大家及时提出来,一起交流学习!

android 自定义Dialog背景透明及显示位置设置的更多相关文章

  1. Android自定义 Dialog 对话框

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

  2. (转)Android 自定义 spinner (背景、字体颜色)

    Android 自定义 spinner (背景.字体颜色) (2012-07-04 17:04:44)   1.准备两张图片,并做好9.png   2.在drawable中定义spinner_sele ...

  3. Android:自定义Dialog大小,显示圆角

    经过测试,可以使用. ----------------------------------------------------------- AlertDialog.Builder builder = ...

  4. Android如何创建背景透明的Dialog

    一:控制Dialog 的背景方法:1.定义一个无背景主题主题<!--去掉背景Dialog--> <style name="NobackDialog" parent ...

  5. Android 自定义dialog类

    首先定制style样式 styles.xml 加入自定义样式 <style name="CustomLoadingDialog"> <item name=&quo ...

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

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

  7. Android—自定义Dialog

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

  8. 设置自定义Dialog背景不变暗

    设置Dialog弹窗的背景不变暗,有两种方式,一种是通过在style中设置,一种是通过代码设置. 一.在style中设置 <style name="dialog_waiting&quo ...

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

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

随机推荐

  1. 2016 版 Laravel 系列入门教程(一)【最适合中国人的 Laravel 教程】

    本教程示例代码见: https://github.com/johnlui/Learn-Laravel-5 在任何地方卡住,最快的办法就是去看示例代码. 本文基于 Laravel 5.2 版本,无奈 5 ...

  2. python 生成器

    摘自:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00138681965108 ...

  3. dell r710 服务器配置RAID5(3块硬盘做RAID5,另外再弄一块做数据冗余盘)

    本文完全转载于:http://www.jb51.net/article/53814.htm,只为做笔记使用 ①4块硬盘做成RAID5 ②3块硬盘做RAID5,一块硬盘做热备盘 这两种配置之间的区别.大 ...

  4. WebService 入门程序(一)

    第一步:定义webService接口 package com.robert.ws.service; import javax.jws.WebService; @WebService public in ...

  5. 坑爹的BFC;块格式上下文

    Formatting context(FC) Formatting context 是 W3C CSS2.1 规范中的一个概念.它是页面中的一块渲染区域,并且有一套渲染规则,它决定了其子元素将如何定位 ...

  6. 【UVA 1586】Ancient Cipher

    题 题意 给你一个只含CHON的有机物的化学式如C6H5OH求相对分子质量 分析 ... 代码 switch #include<cstdio> #include<cctype> ...

  7. 【Gym 100015A】Another Rock-Paper-Scissors Problem

    题 题意 Sonny出石头剪刀布的猜拳策略是 先出R,然后每连续两段都是打败前一段的出拳, 现在问你第n回合打败他要出什么. 分析 他的策略 R P S PSR  SRP PSRSRPRPS SRPR ...

  8. python多态

    多态是面向对象语言的一个基本特性,多态意味着变量并不知道引用的对象是什么,根据引用对象的不同表现不同的行为方式.在处理多态对象时,只需要关注它的接口即可,python中并不需要显示的编写(像Java一 ...

  9. Bsoj 1322 第K小数

    第K小数 Description 现在已有N个整数,你有以下三种操作: 1 A:表示加入一个值为A的整数: 2 B:表示删除其中值为B的整数: 3 K:表示输出这些整数中第K小的数: Input 第一 ...

  10. 在excel批量更改单元格类型后的批量刷新显示

    把E的东西变成完整显示 解决办法: 选中所需要更改的整列数据------>菜单栏的数据选项------>分列