如何建立一个没有windowIsFloating一个透明的活动 [英] How to create a transparent activity WITHOUT windowIsFloating

查看:630
本文介绍了如何建立一个没有windowIsFloating一个透明的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

windowIsFloating 而对于创造一个伟大的一站式对话框风格UI的有很多 ---错误---怪癖。

windowIsFloating while a great one stop shop for creating Dialog styled UI's has many ---bugs--- quirks.

在其中一个我对抗现在的问题是,它赋予顶部祖先的宽度/高度WRAP_CONTENT ,而不是屏幕的宽度/高度。这意味着使用match_parents通常的UI设计将propogate向上,成为WRAP_CONTENT。烦恼的时候。

The one which I'm battling right now is that it assigned the width/height of the top ancestor as "wrap_content" rather than the width/height of the screen. This means the usual UI design of using "match_parents" will propogate upwards to become "wrap_content". Bad times.

所以,我真的想是创建一个活动,并有一个布局,像这​​样:

So, what I would really like is to create an activity, and have a layout like so:

<LinearLayout   android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:orientation="vertical"
                android:id="@+id/containerPageConatiner"
                android:background="@drawable/windowBackground">
    <View           android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"/>
    <FrameLayout    android:id="@+id/singlePane"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:layout_gravity="center_horizontal|center_vertical"
                    android:padding="10dp"/>    
    <View           android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"/>                         
</LinearLayout> 

其产生的UI呈现出单一窗口(@ ID / singlePane)ontop调用它的活性。

Which produces a UI showing a single window (@id/singlePane) ontop of the Activity which called it.

是否有人在的恰到好处的设置来创建一个透明背景的活动所需的样式?

Does anybody have the just right set of styles needed to create a transparent background Activity?

推荐答案

感谢@PolamReddy谁捅了我对答案,我想:

Thanks to @PolamReddy who nudged me towards answer I wanted:

主题 Theme.Translucent.NoTitleBar.Fullscreen 及其祖先包含了所有你需要创建一个半透明窗口的属性。为了从 windowIsFloating 得到一切的除了我经历了祖先堆栈中掏出整套的属性:

The theme Theme.Translucent.NoTitleBar.Fullscreen and its ancestors contains all the attributes you need to create a translucent window. In order to get everything apart from windowIsFloating I went through the ancestor stack and pulled out the entire set of attributes:

<style name="Theme.CustomTheme.TransparentActivity">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowFullscreen">true</item>
</style> 

此样式必须分配到活动的Andr​​oidManifest.xml ,而不是布局的根视图

This style must be assigned to the Activity in the AndroidManifest.xml rather than the root view of a layout.

这篇关于如何建立一个没有windowIsFloating一个透明的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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