1

I add view to WindowManager using the code below (It's brief version), but I want to set the window type it appear below AlertDialog

Windowmanager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

WindowManager.LayoutParams.TYPE_PHONE

mWindowManager.addView(window, window.getLayoutParams());
Jack
  • 693
  • 1
  • 7
  • 25
  • try his https://stackoverflow.com/questions/43626214/android-how-to-add-view-to-windowmanager-and-keep-it-floating-at-the-top-of-my – Anubhav Gupta Sep 10 '18 at 20:36
  • @AnubhavGupta Thank you but the link provide what I already have accomplished, what I want is to have my window appear over my activity but below AlertDialog – Jack Sep 10 '18 at 20:39

1 Answers1

3

You can't do that, at least not how you're thinking.

AlertDialogs are added to your Activity's Window, not a separate one. Adding a View to the WindowManager adds it into a new Window. You can't "inject" a Window into another one.

One way you could do this is to simply add a View to your Activity. Make the root of the Activity a FrameLayout, then put your actual Activity layout inside that FrameLayout. Then just add a View to that root FrameLayout.

TheWanderer
  • 16,775
  • 6
  • 49
  • 63
  • Thank you :) But in my case the view is being positioned based on X , Y coordinates, that's why I had to use WindowManager in the first place, FrameLayout and other layouts doesn't provide such ability, there was a layout in the past that gives such ability but it's deprecated now. Any other suggestions? – Jack Sep 12 '18 at 16:38
  • 1
    @Jack FraneLayouts let you do exactly that. You just can't define coordinates in XML, but use FraneLayout.LayoutParams for positioning – TheWanderer Sep 12 '18 at 16:40
  • Seriously? I'm gonna give it a try right away, oooh man, that would be great and it would save me a lot of hussle – Jack Sep 12 '18 at 16:43