With the "AppCompat" library or "Android Design Support Library" it's a bit different:
In the styles.xml:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:background">#33000000</item> <!-- Or any transparency or color you need -->
<item name="android:windowNoTitle">true</item>
<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>
</style>
(The value @color/transparent is the color value #00000000 which I put in the res/values/color.xml file. You can also use @android:color/transparent in later Android versions.)
Then apply the style to your activity, for example:
Assign it the Translucent theme
With the "AppCompat" library or "Android Design Support Library" it's a bit different:
In the styles.xml:
In the AndroidManifest.xml:
Add the following style in your
res/values/styles.xml
file (if you don’t have one, create it.) Here’s a complete file:(The value
@color/transparent
is the color value#00000000
which I put in theres/values/color.xml
file. You can also use@android:color/transparent
in later Android versions.)Then apply the style to your activity, for example:
Note 1:In Drawable folder create test.xml and copy the following code
// Note: Corners and shape is as per your requirement.
// Note 2:Create xml:
It goes like this:
If you are using
AppCompatActivity
then add this instyles.xml
In
manifest
file you can add this theme to activity tag like thisfor more details read this article