Skip to content

Android ​

After installing SaltUI, configure the Android application and window. Use the shared APIs for theme, screens, and components.

SaltApplication ​

Extend SaltApplication to use the library’s Android initialization and register the actual application class in the manifest.

kotlin
import com.moriafly.salt.ui.app.SaltApplication

class App : SaltApplication()
xml
<application
    android:name=".App">
    <!-- Keep your existing activity and other application settings. -->
</application>

If your app already has an Application subclass, refer to the implementation when integrating it.

Edge-to-edge layout ​

Call SaltUI’s activity extension edgeToEdge() before super.onCreate(). Set the Compose content afterward.

kotlin
import com.moriafly.salt.ui.ext.edgeToEdge

override fun onCreate(savedInstanceState: Bundle?) {
    edgeToEdge()
    super.onCreate(savedInstanceState)
    // setContent { ... }
}

The Sample uses a window theme with a null background.

xml
<style name="Theme.SaltUI" parent="@android:style/Theme.Holo">
    <item name="android:windowBackground">@null</item>
</style>

The layout still needs to account for system bars. If using BasicScreen, apply the provided content padding.

Platform utilities ​

APIUse
WebViewWebView integration based on Accompanist.
RomUtil, ScreenUtilROM and screen helpers.
ThreadUtil, runOnMainThreadMain-thread execution.
WindowUtilSystem bar foreground colors.
kotlin
runOnMainThread {
    // Run work that requires the main thread.
}

WindowUtil.setStatusBarForegroundColor(window, BarColor.White)
WindowUtil.setNavigationBarForegroundColor(window, BarColor.Black)

Choose a system bar foreground with sufficient contrast against the content underneath.

Android version requirements ​

UI requires API 23 or later. Navigation requires API 24 or later. Use Core's OS API for version checks or Adaptive windows for layout decisions. See the source README for Google Play configuration.

Google/Android 是 Google LLC 的注册商标,Salt Player 和糖醋音乐均是寻浔科技(上海)有限公司在中华人民共和国的注册商标