Reputation: 58
Context:
My android library requires to dynamically place views on on top of other target views. Currently I am using WindowManager
for this purpose. I have the viewId
of the target views and get the location coordinates of the views. Now I simply use windowManager.addView()
. Issue faced here is that WindowManager
requires SYSTEM_ALERT_WINDOW
permission which we want to avoid.
I have also tried getWindow().getDecorView().findViewById(android.R.id.content).addView(imageView)
, so that I donot have to use WindowManger but it is causing alignment issues for different phones.
Any help on how we could avoid using WindowManager and still fulfill our purpose at the same time?
Alternative solution: I recently read this stackoverflow answer which said that permission won't be asked if installed from playstore. So I launched my app on playstore but it still asks for permission during runtime. I have also filled this form.
Edit:
ViewOverlay
as suggested by Mike. Issue is that drawables can only be added upto the region where associated View
extends.
ImagegetWindow().getDecorView().findViewById(android.R.id.content).addView(imageView)
Issue is that we get different alignment for different screens.
Screen 1
Screen 2WindowManager
. Require SYSTEM_ALERT_WINDOW
permission which we want to avoid.Upvotes: 0
Views: 291