Floating view with draw over other apps
it uses system alert window with the permission android.permission.SYSTEM_ALERT_WINDOW
under the hood
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.github.javaherisaber:FloatingOverlayView:1.0.2'
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/root_container"
android:layout_width="250dp"
android:layout_height="200dp">
....
</FrameLayout>
</FrameLayout>
FloatingOverlayView(context, R.layout.view_overlay)
.setXOffset(800) // move the banner to the right side
.setOnCreateListener { layout: FloatingOverlayView, view: View ->
// do something with `view`, maybe a close button
}
.setOnCloseListener {
// do something after the banner is closed
}
.create()