Skip to content

Instantly share code, notes, and snippets.

@saifkhichi96
Last active February 24, 2021 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saifkhichi96/653778bf0332b1bf6a888a171dbb190b to your computer and use it in GitHub Desktop.
Save saifkhichi96/653778bf0332b1bf6a888a171dbb190b to your computer and use it in GitHub Desktop.
Themed launch screen on Android
<activity android:name=".LauncherActivity"
android:theme="@style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
class LauncherActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// ...
}
}
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<!-- a solid background color -->
<item android:drawable="@color/colorPrimary"/>
<!-- with a 144dp wide app logo centered on top of the background -->
<item>
<bitmap android:src="@drawable/product_logo_144dp"
android:gravity="center"/>
</item>
</layer-list>
<resources>
<!-- normal AppTheme here -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- customize your theme here -->
</style>
<!-- LauncherActivity theme -->
<style name="AppTheme.Launcher" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment