16

How to create transparent activity in android in that screen tap to dismiss button automatically dismiss the activity. please provide any solution.

enter image description here

Ronak Mehta
  • 5,971
  • 5
  • 42
  • 69
Narasimha
  • 3,802
  • 11
  • 55
  • 83
  • 1
    So I get that you want to have transparent activity, but what do you want to accomplish on tapping issue? – Shobhit Puri May 02 '13 at 06:54
  • 4
    gothrough http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android – Pinki May 02 '13 at 06:55
  • 2
    in manifest, in particular activity you want to be transparent, use android:theme="@android:style/Theme.Translucent" – Saad Asad May 02 '13 at 06:57
  • 1
    Why don't you use a transparent view instead of an activity? You can put a transparent view on your activity. – ACengiz May 02 '13 at 07:02
  • Hi all this problem is solving implemntation is done , thank u very much for sharing information – Narasimha May 06 '13 at 12:54
  • 1
    Possible duplicate of [How to create Transparent Activity in Android?](http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android) – msangel Feb 07 '17 at 12:29

2 Answers2

25

There are two ways to achieve this

  • use the following theme for activity.

android:theme="@android:style/Theme.Translucent"

  • Set background of the activity as a trans parent png image or a transparent code

eg.

android:background="@drawable/transparent_bg"

or

android:background="#33BBFFFF"

this is a semi transparent color

Related Links

How to make a background 20% transparent on Android

Understanding colors on Android (six characters)

  • To dismiss activity on tap implement onTouchListener and when touch event is detected call finish();

Hope it helps !!

Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66
  • 1
    android:background="#33BBFFFF" did not give me a transparent background when applied to the RelativeActivity. It just gave me a white background. -1 – Daniel Viglione Jul 14 '17 at 02:43
9

Works better with noTitleBar to create a full transparent activity

android:theme="@android:style/Theme.Translucent.NoTitleBar"

and remember extends your activity from Activity and not from AppCompactActivity

If you need to use AppCompact then declare a new theme:

<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
    <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>
Pablo Cegarra
  • 20,955
  • 12
  • 92
  • 110