如何去除对话框外的透明深色背景 [英] How to remove transparent dark background outside of dialog box

查看:27
本文介绍了如何去除对话框外的透明深色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除对话框外的透明深色背景.

我尝试过:

final Dialog dialog = new Dialog(this);dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));this.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);dialog.setContentView(R.layout.spinner_layout);getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);

解决方案

您的问题已经得到解答这里

来自链接的代码:

将此添加到您的styles.xml:

然后将主题应用到您的活动中:

I want to remove a transparent dark backgrond outside of dialog box.

I tried with:

final Dialog dialog = new Dialog(this);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));
        this.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.spinner_layout);
         getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);

解决方案

Your question has already been answered here

Code from the link:

Add this to your styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.DoNotDim" parent="android:Theme">
    <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>

And then apply the theme to your activity:

<activity android:name=".SampleActivity" android:theme="@style/Theme.DoNotDim">

这篇关于如何去除对话框外的透明深色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆