Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translucent Activity filling the entire screen

I'd like to have an activity (2) with translucent aspect over another activity (1), aligned at the top of the screen (4).

enter image description here

I have tried assigning these themes to activity number 2:

<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
    <item name="android:windowBackground">@android:color/black</item>
</style>  

<style name="CustomTheme">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowNoTitle">true</item>
</style>    

But the result is always 3.

If I set <item name="android:windowIsFloating">false</item> in the CustomTheme the result is 2.

Can anybody tell me how can I get 4? Thanks!

UPDATE: This is my activity 2 layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" android:background="#0000">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#FFFFFF">

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Menu" android:layout_centerHorizontal="true"/>

    </RelativeLayout>

</RelativeLayout>
like image 810
Xavi Gil Avatar asked May 07 '12 11:05

Xavi Gil


Video Answer


1 Answers

Finally, this theme worked to get a result like image number 4:

  <style name="Theme.CustomTranslucent" parent="android:style/Theme.Translucent">
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:backgroundDimAmount">0.5</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
        <item name="android:background">@android:color/transparent</item>
 </style>  

In my activity 2 layout, I could eihter set android:background="@android:color/transparent" or not set any value at all to make it work.

Thanks to MikeIsrael and Veer for their help.

like image 170
Xavi Gil Avatar answered Oct 07 '22 07:10

Xavi Gil