Skip to content Skip to sidebar Skip to footer

How To Make Translucent Activity

Hellow, I'm trying to create the translucent Activity and define the code in styles.xml but i'm unable to make my activity Translucent. how can i make it translucent can anybody he

Solution 1:

Apply this theme to the required Activity

<stylename="Theme.TransparentInfo"parent="android:Theme"><itemname="android:windowIsTranslucent">true</item><itemname="android:windowBackground">@color/semiTransparentBlack</item><itemname="android:windowContentOverlay">@null</item><itemname="android:windowNoTitle">true</item><itemname="android:windowIsFloating">false</item><itemname="android:backgroundDimEnabled">true</item></style>

value for @color/semiTransparentBlack is #00000000

Solution 2:

Add the following style In your res/values/styles.xml file (if you don’t have one, create it.) Here’s a complete file:

<?xml version="1.0" encoding="utf-8"?><resources><stylename="Theme.Transparent"parent="android:Theme"><itemname="android:windowIsTranslucent">true</item><itemname="android:windowBackground">@android:color/transparent</item><itemname="android:windowContentOverlay">@null</item><itemname="android:windowNoTitle">true</item><itemname="android:windowIsFloating">true</item><itemname="android:backgroundDimEnabled">false</item></style></resources>

Now apply the style to your activity in the manifest

<activityandroid:name=".MainActivity"android:theme="@style/Theme.Transparent">
...
</activity>

Post a Comment for "How To Make Translucent Activity"