Skip to content

Instantly share code, notes, and snippets.

@rezaiyan
Created March 7, 2021 14:49
Show Gist options
  • Save rezaiyan/bc20c2a4af3eba0c9615a7b72c5f97e8 to your computer and use it in GitHub Desktop.
Save rezaiyan/bc20c2a4af3eba0c9615a7b72c5f97e8 to your computer and use it in GitHub Desktop.
Transparent Activity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.transparentactivity">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:name=".App"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true">
<activity android:name=".MainActivity"
android:theme="@style/Theme.Transparent.Activity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
<resources>
<style name="Theme.Transparent.Activity" parent="Theme.MaterialComponents.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment