首先上一张图,看看是不是你想要的效果。

是你想找的效果么?那么就请往下看。
步骤:
1、首先我们先写一个布局文件。这个我就不多说了。直接上代码,写的很粗糙。
命名:dialog_search_service.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><ImageView
        android:id="@+id/search"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@mipmap/dialog_search" /><Space
        android:id="@+id/space"android:layout_width="match_parent"android:layout_height="40dp"android:layout_below="@id/search" /><LinearLayout
        android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/space"android:gravity="center"android:orientation="horizontal"><ProgressBar
            android:id="@+id/progress"style="?android:attr/progressBarStyleLarge"android:layout_width="wrap_content"android:layout_height="wrap_content" /><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="智能硬件搜索中..."android:textColor="@color/white"android:textSize="20sp" /></LinearLayout>
</RelativeLayout>

2、 在values中的style.xml中新建一个style样式。
代码如下:(重要)

<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">true</item><!--半透明--><item name="android:windowNoTitle">true</item><!--无标题--><item name="android:windowBackground">@color/transparent</item><!--背景透明--><item name="android:backgroundDimEnabled">true</item><!-- 如果设置android:backgroundDimEnabled为false.那弹出的对话框背景是亮的--><item name="android:backgroundDimAmount">0.5</item></style>

3、在Activity中使用,直接上代码。

Dialog dialog = new Dialog(LoginActivity.this, R.style.dialog);
View view = LayoutInflater.from(this).inflate(R.layout.dialog_search_service, null);
dialog.setContentView(view);
//setting size
Window dialogWindow = this.getWindow();
WindowManager m = getWindow().getWindowManager();
Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
//手机横竖屏时候
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){p.height = (int) (d.getHeight() * 0.2); // 高度设置为屏幕的p.width = (int) (d.getWidth() * 0.7); // 宽度设置为屏幕的
}else if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){p.height = (int) (d.getHeight() * 0.3); // 高度设置为屏幕的p.width = (int) (d.getWidth() * 0.4); // 宽度设置为屏幕的
}
dialogWindow.setAttributes(p);
dialog.show();

4、完工!

Android中背景透明的Dialog相关推荐

  1. html背景透明图片不透明,css中背景透明的图片不透明怎么解决

    css中背景透明的图片不透明怎么解决 一.使用滤镜解决img { background: transparent; -ms-filter: "progid:DXImageTransform. ...

  2. Android背景透明的 Dialog

    2019独角兽企业重金招聘Python工程师标准>>> 一:控制Dialog 的背景方法: 1.定义一个无背景主题主题 <!--去掉背景Dialog--> <sty ...

  3. 背景透明的 Dialog

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

  4. Android中修改弹出dialog背景无色透明,弹出时有遮罩

    先在styles.xml中写入下面样式 1 <style name="dialog" parent="@android:style/Theme.Dialog&quo ...

  5. android alertdialog 背景透明,Android Alertdialog弹出框设置半透明背景

    自定义AlertDialog基本步骤: 1.写一个layout布局,使用inflater生成对应view对象 2.新建AlertDialog.Builder对象builder 3.builder设置自 ...

  6. HTML中背景透明有阴影,透明PNG在网页有阴影的解决方法

    做自己的SS站LOGO时,我用的是PNG图片,PS时做的是透明背景,上传到网站后在本机测试也是透明(如图一),不过之后在很多别人的电脑上看时图片出现了水渗般的背景色(如图二),问了很多朋友,以为与电脑 ...

  7. Android 设置背景透明

    如果你想在XML文件中预设置 半透明:设置该view的alpha属性 = 0.5即可 透明 android:background="#000000" 如果你想在java代码中动态设 ...

  8. android自定义键盘遮挡,android中键盘遮挡了dialog里的内容怎么处理

    在编辑框输入内容时会弹出软键盘,而手机屏幕区域有限往往会遮住输入界面,我们先看一下问题效果图: 输入用户名和密码时,系统会弹出键盘,造成系统键盘会挡住文本框的问题,如图所示: 输入密码时输入框被系统键 ...

  9. 实现背景透明的方法,兼容ie6/7/8等浏览器

    今天登录支付宝,发现支付宝首页首页改版了,给人一种清新,自然,简洁的感觉,另外发现支付首页的登录界面用的一种半透明的背景,刚开始以为是用的rgba方法,但是发现在ie6.7.8中登录界面的背景也是同样 ...

  10. Android 自定义Dialog背景透明及显示位置设置

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

最新文章

  1. 蚊子已经很可怕了,而这些吸血昆虫能让你感受真正的恐惧
  2. linux冒泡算法程序,用蛮力法解决冒泡排序 - linux-tao的个人空间 - OSCHINA - 中文开源技术交流社区...
  3. 014_html折行
  4. typescript 怎么表示当前时间减一个月_TypeScript 入门知识点总结
  5. Java面试中常问的Spring方面问题
  6. 7-1:C++的IO流
  7. php fetch mode,odbc_fetch_into
  8. python曲线拟合绘图_python – 将曲线拟合到分段图像
  9. 整理一下第一次参加华为大数据挑战赛自己的一些收获吧(正式赛篇阶段一)
  10. 第一周学习报告(关于string)
  11. 全方位构建信创生态体系,焱融科技完成海光 CPU 生态兼容性认证
  12. 微信公众号的附件链接怎么弄
  13. 28335 flash 下载到flash带仿真器可以,重新上电不能自动运行
  14. 餐饮管理系统开源java_java课程设计餐饮管理系统
  15. 阿里巴巴中间件之Seata
  16. Android Service保活的几种方法总结
  17. 深入探讨go.mod +incompatible
  18. 快速对Oracle数据库的了解 ---2
  19. WAS ND基本概念介绍
  20. i5 12500h参数 i5 12500h核显什么水平

热门文章

  1. 由spin_lock_bh想到的一些事
  2. TC中的HTB队列简单创建与过滤
  3. Linux内存映射——mmap
  4. map的基本操作总结C++
  5. 【紫书第十章】数论与概率入门
  6. 【紫书第五章】String、结构体、部分STL的常见用法
  7. 计算数据个数mysql thinkphp_ThinkPHP5 (mySQL) 统计各个时间段内的订单量
  8. kettle linux下的目录怎么看_Linux系统各目录下指令解析
  9. android拉勾轮播,拉勾网顶部轮播图的实现(一)以及简单闭包的应用
  10. matlab 时间步 图,MATLAB运行显示输入和目标具有不同的时间步?