Simple understanding of WindowManager

WindowManager is an interface as follows:

public  interface WindowManager extends ViewManager {
...
}

Its Nested Classes have three:

       WindowManager.LayoutParams
       WindowManager.BadTokenException
       WindowManager.InvalidDisplayException

Here we mainly look at the WindowManager.LayoutParams class

From the source code, we can see the inheritance and implementation relationship of this class. Although there are 2000+ lines of code (that is , most of the code of the WindowManager interface is of this type), most of them are constants. My understanding is that some define the layout. The parameters of (maybe I will change my understanding as I go deeper)

 These parameters are recommended for everyone to read https://www.cnblogs.com/henu529/p/7061583.html this blog (if there is any infringement, please let us know immediately, thank you!!!!)

 

Here's a little chestnut for you to look at:

Give each attribute of mParams to viewToast for use

params.height=WindowManager.LayoutParams.WRAP_CONTENT;
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
         // Set the flag so that the user cannot send keyboard or Button events to Window and the screen will always be highlighted as long as the window is visible 
        params.flags= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ;
 //                 |WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; 
        params.format= PixelFormat.TRANSLUCENT;
        params.type=WindowManager.LayoutParams.TYPE_PHONE;
        params.gravity=Gravity.LEFT+Gravity.TOP;
        params.setTitle("Toast");
        params.x=SpUtil.getInt(AddressService.this,ConstantValue.LOCATON_X,0);
        params.y=SpUtil.getInt(AddressService.this,ConstantValue.LOCATON_Y,0);

        viewToast=View.inflate(AddressService.this,R.layout.toast_view,null);
        tv_toast=(TextView)viewToast.findViewById(R.id.tv_toast);

        mWindowManager.addView(viewToast, mParams);

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324863691&siteId=291194637