其他分享
首页 > 其他分享> > Android 悬浮窗口

Android 悬浮窗口

作者:互联网

   WindowManager wm = (WindowManager)getApplicationContext().getSystemService(Context.WINDOW_SERVICE);     
   WindowManager.LayoutParams params = new WindowManager.LayoutParams();     
   params.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;     
   params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;    
   
   params.width = WindowManager.LayoutParams.WRAP_CONTENT;     
   params.height = WindowManager.LayoutParams.WRAP_CONTENT;     
   params.format = PixelFormat.RGBA_8888;   
   TextView tv = new TextView(this);    
   tv.setText("这是悬浮的提示信息");   
   wm.addView(tv, params); 
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

 

标签:窗口,悬浮,WindowManager,LayoutParams,params,tv,WRAP,new,Android
来源: https://blog.51cto.com/u_15298588/3034256