Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create a transparent Activity in Android

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 418
    Comment on it

    You have to add a theme attribute in the Android manifest file under activity section. So that only that particular activity will become transparent.

    After the above step, add background attribute to your layout file as shown below:

    <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#80000000" tools:context=".MainActivity"></linearlayout>
    

    android:background="#80000000", this will make the layout transparent.

    Programatically make Activity transparent

    Apart from declaring attribute in Android manifest file, you can make Activity transparent programatically also. Below is the code for the same:

    Window window = this.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: