You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check example module [kotlin](https://github.com/hyuwah/DraggableView/blob/master/example/src/main/java/io/github/hyuwah/draggableview/MainActivity.kt), [java](https://github.com/hyuwah/DraggableView/blob/master/example/src/main/java/io/github/hyuwah/draggableview/JavaMainActivity.java) for actual implementation
191
194
195
+
### Draggable over other App (Overlay)
196
+
197
+
> Tested working on API 25, 28 & 29
198
+
> Not working as of now on API 19 (on investigation)
199
+
200
+
This is the simplest way to setup an overlay draggable view, assuming it will be started from an activity.
201
+
202
+
Some notes:
203
+
* On the activity, implement `OverlayDraggableListener`
204
+
* We need to make the view programmatically, here i'm creating a TextView, you can also inflate a layout
205
+
* You need to make the view as global variable
206
+
* Here i'm omitting the params / using default params for `makeOverlayDraggable()`
207
+
208
+
This will create an overlay draggable view that tied to the activity's lifecycle, from `onCreate` until `onDestroy`.
209
+
It is recommended to create the overlay draggable view on a `Service` instead of an activity, because of that reason.
Also, before adding the view to WindowManager, you need to check if the device support overlay and required permission
250
+
251
+
```kotlin
252
+
privatefuncheckOverlayPermission() {
253
+
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M&&
254
+
!Settings.canDrawOverlays(this)
255
+
) {
256
+
// Get permission first on Android M & above
257
+
val intent =Intent(
258
+
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
259
+
Uri.parse("package:$packageName")
260
+
)
261
+
startActivityForResult(intent, 1234)
262
+
} else {
263
+
// overlayView & params are global variable
264
+
windowManager.addView(overlayView, params)
265
+
}
266
+
}
267
+
```
268
+
269
+
Check the example here: [Kotlin](https://github.com/hyuwah/DraggableView/blob/master/example/src/main/java/io/github/hyuwah/draggableview/OverlayDraggableActivity.kt)
270
+
271
+
---
192
272
## Accompanying Article
193
273
194
274
*[Implementasi DraggableView di Android (Bahasa)](https://medium.com/@hyuwah/implementasi-draggable-view-di-android-eb84e50fbba9)
0 commit comments