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

代码如下:

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. 第五章:javascript:队列

    队列是一种列表,不同的是队列只能在末尾插入元素,在队首删除元素.队列用于存储按顺序排列的数据.先进先出.这点和栈不一样,在栈中,最后入栈的元素反被优先处理.可以将队列想象成银行排队办理业务的人,排队在 ...

  2. Linq 分页不可缺少的两个方法

    //LINQ分页的方法 //1.获取总页数 public int GetPageCount(int pageSize)//pageSize是每页的行数 { //先查出总共有多少行 int rowCou ...

  3. hdu5012 bfs

    比较简单的题 搜索4个方向,维护位子的值. #include<stdio.h> #include<string.h> #include<queue> using n ...

  4. USACO 3.2 kimbits DP

    自己YY了个DP:设f[n][l]为n位数中包含不超过l个1的总个数 f[n][l]=f[n-1][l]+f[n-1][l-1] 然后用_search()从高位向低位扫描即可,tmp记录当前已记下多少 ...

  5. Openjudge 8782 乘积最大

    伤心,感冒了根本没精力肝题,只能做点小的 描述 今年是国际数学联盟确定的“2000——世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰90周年.在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力 ...

  6. POJ1679The Unique MST(次小生成树)

    The Unique MST Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25203   Accepted: 8995 D ...

  7. xml 嵌入式资源

    使用Ibatis总是说未能加载相应的sqlmap.xml,原来是 xml以内容方式,而不是嵌入式方式载入Dll中

  8. Jsonp简单认识(后端使用的是asp.net mvc)

    一.Jsonp简介:由于浏览器基于安全有同源策略(同源策略阻止从一个源加载的文档或脚本获取或设置另一个源加载的文档的属性)机制,所以前端无法使用Ajax来获取来获取其他域名下返回的数据,而Jsonp可 ...

  9. LinkedBlockingQueue和ConcurrentLinkedQueue详细用法

    1.LinkedBlockingQueue<E>:java.util.concurrent API中的解释: public class LinkedBlockingQueue<E&g ...

  10. 新浪微博客户端(32)-设置相册图片的contentMode

    DJStatusPhotoView.m #import "DJStatusPhotoView.h" #import "UIImageView+WebCache.h&quo ...