Android appwide view overlay (HUD)

只谈情不闲聊 提交于 2019-12-05 15:55:31

I know this is an old question, but I thought I'd answer anyway since this helped me out. I was trying to get an HUD running in an openGL game and this works perfectly for that.

Since you already have the HUD displaying using the window manager, all you need to do to keep it persistant between activities is to call windowManager.addView(hudView, lp); in each activity's onResume() method. Not sure what the memory implications are though (i.e. is the view being disposed of when the window manager removes it from the screen upon switching activities), but at least it will keep the HUD up throughout the entire app.

I read that you stopped working with android, but maybe for further readers:

You missed the flag WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,. Best to implement as a view inflated by a service. Don't call it in every activity in onResume.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!