Global Floating Window Framework based on Jetpack Compose
- Using Compose code to describe the floating window interface.
- ViewModel support.
- Support for draggable floating windows.
- Dialog components based on the Application Context.
- Add on settings.gradle.kts
dependencyResolutionManagement {
repositories {
maven { url = uri("https://jitpack.io") }
}
}- Add
compose-floating-windowDependency
dependencies {
implementation("com.github.ArthurKun21:compose-overlay-window:<tag>")
}Add to AndroidManifest.xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />When you want to show the floating window while on the Activity, you can use the following code:
val floatingWindow = ComposeFloatingWindow(applicationContext)
floatingWindow.setContent {
FloatingActionButton(
modifier = Modifier.dragFloatingWindow(),
onClick = {
Log.i("")
}) {
Icon(Icons.Filled.Call, "Call")
}
}
floatingWindow.show()When you want to show the floating window while on the Service, you can use the following code:
val floatingWindow = ComposeServiceFloatingWindow(applicationContext)
floatingWindow.setContent {
FloatingActionButton(
modifier = Modifier.dragFloatingWindow(),
onClick = {
Log.i("")
}) {
Icon(Icons.Filled.Call, "Call")
}
}
floatingWindow.show()See Sample Apps.
Apache 2.0 License
