Question

I have overlay View managed by WindowManager, just like in this question.

Briefly, it looks like this:

WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
my_view_layout_params = new WindowManager.LayoutParams(
       WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
       WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
       PixelFormat.TRANSLUCENT);

wm.addView(my_view, my_view_layout_params);

It works, but if i need to change layout params, i need to remove View and add it again, like that:

wm.removeView(my_view);
wm.addView(my_view, my_view_layout_params);

It looks not very beautiful. I tried to do my_view.setLayoutParams(my_view_layout_params), but it does not work unfortunately. How can i do it?

Was it helpful?

Solution

WindowManager has an updateViewLayout() member... surely that's exactly what you want?

windowManager.updateViewLayout(my_view, my_view_layout_params);

OTHER TIPS

You can use this:

wm.updateViewLayout(my_view,my_view_layout_params);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top