Android: how to create transparent or opeque background
March 22, 2010 31 Comments
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:
- create an activity
- set activity’s theme as “@android:style/Theme.Translucent” in AndroidManifest.xml
- 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:
- create an activity
- set activity’s theme as “@android:style/Theme.Translucent” in AndroidManifest.xml
- declare opaque_back a color with setting alpha value such as #29000000(blackish), in …/res/colors.xml
- set activity’s layout background with this color in such as yourlayout.xml <LinearLayout
android:background=”@color/opaque_back”> … </…> - that’s all
Have a nice Android journey.
References: