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)