關於安卓中 WindowManager.LayoutParams()的兩種方式
阿新 • • 發佈:2019-01-10
wParams.type = LayoutParams.TYPE_PHONE ; //設定window type,type是關鍵,這裡的"2002" 表示系統級視窗,你也可以試試2003
wParams.format = PixelFormat.RGBA_8888; //// 設定圖片格式,1 效果為背景透明
wParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCHABLE;
wParams.gravity = Gravity.RIGHT| Gravity. CENTER_VERTICAL;// 調整懸浮視窗至右側中間
wParams.width = WindowManager.LayoutParams.WRAP_CONTENT;// 設定懸浮視窗長寬資料
wParams.height =WindowManager.LayoutParams.WRAP_CONTENT;
wManager.addView(bb, wParams);//bb新增view到螢幕
//wManager.removeView(bb); //從螢幕上刪除bb(view)
//懸浮視窗需新增許可權<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
wParams.format = PixelFormat.RGBA_8888; //// 設定圖片格式,1 效果為背景透明
wParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCHABLE;
wParams.gravity = Gravity.RIGHT| Gravity. CENTER_VERTICAL;// 調整懸浮視窗至右側中間
wParams.width = WindowManager.LayoutParams.WRAP_CONTENT;// 設定懸浮視窗長寬資料
wParams.height =WindowManager.LayoutParams.WRAP_CONTENT;
wManager.addView(bb, wParams);//bb新增view到螢幕
//wManager.removeView(bb); //從螢幕上刪除bb(view)
//懸浮視窗需新增許可權<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />