Android: how to create transparent or opeque background

You can implement application styles as you like in android platform. If you want to create a transparent background Activity then follow the steps below.

Transparency of background:

  1. create an activity
  2. set activity’s theme as “@android:style/Theme.Translucent” in AndroidManifest.xml
  3. that’s all

If it is needed to have a UI with semi-transparent background, and to define opacity then use this technique with Theme.Translucent. If you set the color of the UI layout as #29000000, the first hex 2-digit(#29) represents alpha channels of color and set opacity. If value is 00 that means 100% transparent. if value is set FF it will be opaque, it can be any value in 00 to FF.

Opaqueness of background / Opacity:

  1. create an activity
  2. set activity’s theme as “@android:style/Theme.Translucent” in AndroidManifest.xml
  3. declare opaque_back a color with setting alpha value such as #29000000(blackish), in/res/colors.xml
  4. set activity’s layout background with this color in such as yourlayout.xml  <LinearLayout
    android:background=”@color/opaque_back”> … </…>
  5. that’s all

Have a nice Android journey.

References: