Question

I created a custom theme which looks similar like a popup and appears above the main Activity menu when any icon is clicked there, so this popup should look somehow translucent for a better look.

Basically the theme works, but the translucency doesn't. The theme itself must not be translucent, because I don't want the popup Activity to fill the whole screen. I use a ScrollView which contains a LinearLayout. This layout has margins, so it doesn't fill the whole screen. But the translucency of this layout doesn't work. It's just black. Why this is so?

Theme:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="Theme.Dialog" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:background">@null</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>
</resources>

xml of popup Activity:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@null">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_margin="5dp"
        android:background="#AA000000">

        //...more content //
    </LinearLayout>
</ScrollView>
Was it helpful?

Solution

I found the answer on my own. I need to add another item parameter to my theme to get transparency working:

<item name="android:windowBackground">@android:color/transparent</item>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top