How to Draw Widgets Over Other Apps in Android

In this tutorial, we are going to learn how to create simple floating widget that allow the user to drag them across the screen in android.


Draw over other apps is also known as Floating widget. A widget that can be drawn on home screen or top of any other application which will be used for quick actions to the services provided by the application like FB Chat.


Android system allows applications to draw over other application if the application has android.permission.SYSTEM_ALERT_WINDOW permission.

For android version <= API22, this permission is granted by default. But for the android versions running API > 22, we need to check for the permission runtime.

If the permission is not available, we will open permission management screen to allow the user to grant permission using Settings.ACTION_MANAGE_OVERLAY_PERMISSION intent action. This will open below screen facilitate user to grant the required permission.

Foreground Service

In order to future interaction with our application like dragging and so on, we need to starts the foreground service. It means that this service will not be killed in a first line when the system needs extra memory. User must be aware of this type of service and this is why the ongoing notification appears.

Widget Movement

To make the widget move by dragging, we are going to override OnTouchListener() to listen to drag events and change the position of the view has in the screen.


Complete Source code available here.


I hope you will like the article and it will definitely help you to make your apps more productive. In case of any confusion or query, feel free to ask. And if you found this tutorial to be useful, Share with others.

About Durga Chiranjeevi

I’m a normal guy, engineer by education who is passionate about Programming and Internet. An android enthusiast, now moving for cross platforms and game development.