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:

Advertisements

About M Moniruzzaman
A passionate software engineer, have been developing applications on various platforms such as Android, iPhone, .Net (C#) technologies and web based ASP.NET, PHP, JavaScript, jQuery technologies for more than 10 years. Especially I have expertise on developing applications for Android and iPhone, as well as service oriented, client-server based applications where clients will be reside on Android/iPhone that communicate with WCF(.NET) service hosted on server. I have completed certification in Microsoft Certified Professional Developer (MCPD) on .Net 4 . I have completed my graduation in -- B.Sc. (Engineering) in Computer Science and Engineering, ShahJalal University of Science and Technology, Bangladesh. Thanks, M. Moniruzzaman (Zaman)

25 Responses to Android: how to create transparent or opeque background

  1. Michael says:

    Brilliant! Works like charm

  2. sat says:

    Awesome ! , Understood something new !

  3. JC2life says:

    Works fine, but it returns the Title Bar only in the activity with the translucent background. I used the NoTitleBar option into the Manifest.

  4. balaji says:

    Its really cool. Android seems to have really technical interface. Its really hard for casual developers to guess that the opacity field is part of color code.

  5. Dattatraya says:

    I want to change the opacity dynamically according to user requirement. It is possible?

  6. Nitin Bali says:

    how can i make some animation in this transparent layer plz let me know other than that its awesome functionality Thanks 🙂

  7. Carlos says:

    Thanks for this. It was really helpful.

  8. Daniel Patterson says:

    Or just go to your xml file and set the android:background=”#29000000″
    Where the 0s represent the color in hexadecimal i.e. white = FFFFFF. The 29 represents the opacity of the color.

  9. Eduardo says:

    It’s ok but one thing that I wish most people giving informtion should learn is to not only include partial answers to the problem. In other words show the entire example or the entire line of code whether it goes in the XML or in the application code.

    There is nothing more frustrating than good advice but it’s not all there!!

  10. Reblogged this on Smartphone & E-Commerce and commented:
    Tạo activity dạng một form động cho app – Android Code

  11. dfdsfdsf says:

    great tutorial

  12. Arsalan says:

    Its solved my problem. I Understood the transparency.

  13. jogin says:

    how to do this activity

  14. amit says:

    hyy can ny 1 plzz tell me how n where to make this activity …???? n wht does it mean ???

  15. lyman li says:

    thanks, your post save me a lot of time. thanks.

  16. Harish V says:

    Yes, agree with other posts. I struggled with so many settings before this, it works like a charm, thanks much

  17. Pingback: Android: create transparent or opeque background | Nishanth Rocker World

  18. adomax says:

    I am regular reader, how are you everybody? This post posted at this website is in fact
    good.

  19. Pingback: android backgroundPhone News | Phone News

  20. Pingback: How to make a ListView transparent in Android? | ASK AND ANSWER

  21. Shoorjo says:

    which software I can use for use code

  22. My brother suggested I might like this web site.He used to be totally right. This publishactually made my day. You cann’t imagine simply how a lot time I hadspent for this information! Thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: