Skip to main content

Android Theme

There is an extension to change the Android Theme for Android View, DataBinding/ViewBinding, Fragment.

Setup

Add the katalog-ext-androidtheme package. The katalog-androidview package is required to use Android View, DataBinding/ViewBinding and Fragment too.

dependencies {
implementation("com.moriatsushi.katalog:katalog:`LATEST_VERSION`")
implementation("com.moriatsushi.katalog:katalog-androidview:`LATEST_VERSION`")
implementation("com.moriatsushi.katalog:katalog-ext-androidtheme:`LATEST_VERSION`")
}

Examples

You can set the Android Theme when calling registerKatalog. The background color will be the value specified by android:colorBackground.

res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="MyTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:colorBackground">#FF0000</item>
</style>
</resources>
registerKatalog(
title = "Android Sample",
extensions = listOf(
AndroidThemeExt(R.style.MyTheme) // add this line
)
) {
view("Text View") {
TextView(context).apply {
text = "Hello, World"
}
}
}