为 android 活动设置半透明背景? [英] To have a transluscent background for an android activity?

查看:27
本文介绍了为 android 活动设置半透明背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望某个活动具有半透明背景,以便可以在该活动下方看到上一个活动.类似于在后台播放的视频上弹出的半透明菜单.

I wish to have a transluscent background for an activity, so that the previous activity can be seen beneath this activity. Something like a transluscent menu that pops up over a videa being played in the background.

这可能吗?你能告诉我怎么做吗?

Is this possible? Can you tell me how?

注意:我无法使用 android 的默认半透明主题,因为我正在为我的应用程序使用我自己的自定义背景和主题.

Note:I cannot use the default transluscent theme from android, since I am using my own customised background and theme for my application.

请帮忙.下面是我的 style.xml,其中 my_btn 和 my_list 是选择器:

Pls help. Below is my style.xml wherein my_btn and my_list are selectors :

<?xml version="1.0" encoding="utf-8"?>
<resources> 
    <style name="btnstyle" parent="@android:style/Widget.Button">
        <item name="android:textColor">#FFFFFF</item> 
        <item name="android:background">@drawable/my_btn</item>         
    </style>    
    <style name="liststyle" parent="@android:style/Widget.ListView">
        <item name="android:listSelector">@drawable/my_list</item>
    </style> 
    <style name="theme" parent="android:Theme.Translucent"> 
        <item name="android:windowBackground">@drawable/background</item>   
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:buttonStyle">@style/btnstyle</item>
        <item name="android:listViewStyle">@style/liststyle</item>  
    </style>
    </resources>

推荐答案

在 AndroidManifest.xml 中将 Translucent 主题应用到您的 Activity

Apply Translucent theme to your activity in AndroidManifest.xml

<activity android:theme="@android:style/Theme.Translucent">

这篇关于为 android 活动设置半透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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