Theming and Styling¶
The SAP BTP SDK for Android supports the standard Android Styles and Themes approach, allowing you to either readily adopt the SAP Fiori with Horizon Design Language for Android "out of the box," or customize the look and feel of your app to support your own requirements.
Prerequisites¶
- The latest version of Android Studio
Installation¶
dependencies {
implementation 'com.sap.cloud.android:fiori-theme:${versions.sapCloudAndroidSdk}'
}
Available Libraries¶
The following libraries are available.
| Gradle Dependency Line | Library |
|---|---|
com.sap.cloud.android:fiori-theme:${versions.sapCloudAndroidSdk} |
SAP Fiori with Horizon Theme |
Using the SAP Fiori with Horizon Theme¶
If you're using the standard Android approach and referring to your app's theme with @style/AppTheme in AndroidManifest.xml, you'll need to update the styles.xml file in the res\values folder. To apply the SAP Fiori with Horizon Theme, set one of the following themes as the parent of your AppTheme. Choose based on your desired application behavior:
<style name="AppTheme" parent="Theme.Tonal.Horizon">
<!-- Customize your theme here - see below -->
</style>
or
<style name="AppTheme" parent="Theme.Fiori.Horizon">
<!-- Customize your theme here - see below -->
</style>
Use the first approach if you want your application to adopt the new Tonal Horizon theme. This theme is visually compatible with standard Material 3 components that use the same theme, as Theme.Tonal.Horizon is a Material 3 theme itself. It follows the latest Material 3 best practices.
The first approach also provides support for medium- and high-contrast theme overlays. For more information regarding medium- and high-contrast themes see ColorContrastOptions.
The second approach continues to be supported for now for applications that aren't ready to migrate to the latest Material 3 standard. However, it will be deprecated at some point.
You may also wish to use the Fiori definitions for the "NoActionBar", "AppBarOverlay" and "PopupOverlay" styles, by doing the following:
<style name="AppTheme.NoActionBar" parent="Theme.Tonal.Horizon">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.Fiori.Horizon.AppBarOverlay" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.Fiori.Horizon.PopupOverlay" />
Using these styles will result in your app using the Primary, PrimaryDark and Accent colors defined by the SAP Fiori with Horizon Theme, as well as the Fiori Search View Style and Button Style. Your app will also use SAP's custom Fiori 72 font as the default font.
Customizing the SAP Fiori with Horizon Theme¶
The SAP Fiori with the Tonal Horizon Theme offers several styles you can customize if you want to modify the theme. Add these customizations as elements of your overridden AppTheme. For instance, to change the primary color from the standard Fiori primary color to red (assuming "red" is defined in your colors.xml file), make the following change:
<style name="AppTheme" parent="Theme.Tonal.Horizon">
<item name="colorPrimary">@color/red</item>
</style>
You can also customize the buttonStyle and searchViewStyle attributes.