显示在其他正在运行的活动(Android版)的顶部对话框? [英] Showing dialog on top of another running activity (Android)?

查看:95
本文介绍了显示在其他正在运行的活动(Android版)的顶部对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了与Android平台上的另一个应用程序运行的应用程序。其他应用程序通过我的应用程序的信息,与意图,根据用户操作。我希望,我也许能弹出一个半透明的信息对话框,在其他应用程序的顶部。我跟着其中一个例子,在这里,但它带给我的应用程序回到前台,并把对话最重要的是。这可能吗?我希望以避免与其他开发商成立的意图听众,和诸如此类的东西的工作,以示我的信息。

I've created an application that works with another app on the Android platform. The other application passes my app information, with intents, based on user action. I was hoping, that I might be able to pop a translucent information dialog, on top of the other application. I followed one of the examples, here, but it brought my application back to the foreground and put the dialog on top of that. Is this possible? I'm hoping to avoid having to work with the other developers to set up intent listeners, and whatnot, to show my information.

推荐答案

如果你想处理另一个活动之上弹出,您必须使用广播监听器实施。
至于半透明特性而言,你可以添加下面的一行在实例化一个新的对话框:
对话框=新DialogBox的(这一点,R.style.Transparent);

If you want to handle a popup on top of another activity, you must use broadcast listener for implementation. As far as translucent property is concerned, you can add the below line while instantiating a new dialog: dialog = new DialogBox(this, R.style.Transparent);

有关实施这一点,你需要写在styles.xml下面这段code的,这将驻留在该项目的值文件夹中。

For implementing this, You need to write the following piece of code in styles.xml which will reside in values folder of the project.

      <style name="Transparent">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowAnimationStyle">
         @android:style/Animation.Translucent</item>
        <item name="android:windowBackground">@drawable/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorForeground">#fff</item>
      </style>

同样,你需要添加下面的行colors.xml文件present价值观文件夹:

Similarly, You need to add the below line in colors.xml file present in values folder:

     <drawable name="transparent">#00000000</drawable>

另外,还可以尝试了这一点:要添加模糊背景图片

Also, you can try this out: To Add Blur to the background image

     WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();  
     lp.dimAmount=0.0f;  
     dialog.getWindow().setAttributes(lp);  
     dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);  

希望这会有所帮助。

Hope this will help.

谢谢!

这篇关于显示在其他正在运行的活动(Android版)的顶部对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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