Android has three types of windows
Application Windows (application window): Includes windows that all applications create themselves, and the system is responsible for displaying the windows before applying them.
Sub window: For example, if you apply a custom dialog box or an Input method window, the child window must be attached to an application window (setting the same token).
System window: System design, not attached to any application window, for example, status bar, navigation bar (Navigation bar), wallpaper (wallpaper), Caller ID window (phone), Lock screen window ( Keyguard), Information tip window (Toast), Volume adjustment window, mouse cursor, and so on.
Popupwindow belongs to sub window, so be sure to have a view to attach
There are two main methods of
showatlocation (View parent, int gravity, int x, int y)
Show Popupwindow in a special position
Showasdropdown (View anchor, int xoff, int yoff)
Displays the position of the lower left x offset and Y offset in the view anchor
public void On_effect (final View v) {/*data.src_bmp=myview.bmp;intent intent=new Intent (drowview.this,bmpeffect.class ); StartActivity (intent); *///front that linear layout disappears log.e ("on_effect", "ing");p op_num=0;//relayout2.setvisibility (View.gone) ;//relayout.setvisibility (view.visible); Show=true; int[] location = new Int[2]; V.getlocationonscreen (location); LOG.E ("+location[0", "" +location[1]); Mypopwindow.showatlocation (V, gravity.bottom| Gravity.center_horizontal, 0,0);}
Android system window for suspension and monitoring of Ontouch events
public void On_show (final View v) {//showpop= (linearlayout) Findviewbyid (R.ID.LINEARLAYOUTPOP1);//LOG.E ("show", "ing" ); if (Pop_show_flag==false) {showpop.setvisibility (view.visible); Leftpop.invalidate (); Windowmanager.removeviewimmediate (Leftpop);//leftpop.setontouchlistener (L) leftpop=getlayoutinflater (). Inflate ( R.layout.leftpopwindow2, NULL); Leftpop.setontouchlistener (MyListener); Windowmanager.addview (Leftpop, Windowmanagerparams); Windowmanager.updateviewlayout (leftpop,windowmanagerparams);p op_show_flag=true; LOG.E ("Show", "flase");} Else{windowmanager.removeviewimmediate (Leftpop); Leftpop=getlayoutinflater (). Inflate (R.layout.leftpopwindow, NULL); Leftpop.setontouchlistener (MyListener); Windowmanager.addview (Leftpop, windowmanagerparams); Windowmanager.updateviewlayout (leftpop,windowmanagerparams);p op_show_flag=false; LOG.E ("Show", "true");}}
Parameter initialization for window.
Windowmanager=this.getwindowmanager (); windowmanagerparams=new windowmanager.layoutparams (); Windowmanagerparams.format = pixelformat.rgba_8888;; Windowmanagerparams.type = Android.view.WindowManager.LayoutParams.TYPE_APPLICATION; windowmanagerparams.flags=android.view.windowmanager.layoutparams.flag_not_touch_modal| Android.view.windowmanager.layoutparams.flag_not_focusable|android.view.windowmanager.layoutparams.flag_split_ touch;//|android.view.windowmanager.layoutparams.flag_not_touchable;//windowmanagerparams.flags= Android.view.windowmanager.layoutparams.flag_not_touch_modal|android.view.windowmanager.layoutparams.flag_not_ Focusable;windowmanagerparams.gravity=gravity.left| gravity.center_vertical;
Format is transparent and can be seen below
Type can try the Type_phone in the System window, or the other, the larger the window value, the more it is on the top,
Flag represents the parameters of the view, indicating whether it can be touched, can be focused, and so on.
Grvavity represents the location of the view, and so on.
Leftpop.setontouchlistener (MyListener); In this setting Ontouch listener, you can manually call the following Ontouch
</pre><pre name= "code" class= "HTML" >mylistener=new Ontouchlistener () { @Overridepublic Boolean OnTouch (View V, motionevent event) {//TODO auto-generated method STUBLOG.E ("Top", "ing");//v.my_drow_view.ontouchevent (event);//Call here the following Ontouchreturn true;}};
Popupwindow Click outside the view to disappear
Popupwindow.setfocusable (TRUE);
In this way, when displayed, the Popupwindow gets the focus, and the later content is inactive.
However, it is not possible to click on the other parts of the screen to make it disappear and return to the key.
This time to set a backgrounddrawable for Popupwindow, if you have already defined the layout, afraid of destroying the style, only need to set an empty drawable.
Popupwindow.setbackgrounddrawable (New paintdrawable ());