在做截屏分享时,发现调用系统长截屏导致弹出的窗口被多次拼接,经多次测试发现,将弹窗显示位置上移即可解决 Window window = getWindow(); WindowManager.LayoutParams attributes = window.getAttributes(); attributes.gravity = Gravity.RIGHT|Gravity.TOP; attributes.y = DensityUtil.dp2px(context,260); attributes.width= WindowManager.LayoutParams.MATCH_PARENT; window.setAttributes(attributes); window.setAttributes(attributes); window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); window.setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
弹窗的style <style name="ScreenShotStyle" parent="android:style/Theme.NoTitleBar"> <item name="android:windowFrame">@color/transparent</item><!-- 边框 --> <item name="android:windowIsFloating">true</item><!-- 是否浮现在activity之上 --> <item name="android:windowIsTranslucent">false</item><!-- 半透明 --> <item name="android:windowNoTitle">true</item><!-- 无标题 --> <item name="android:windowBackground">@color/transparent</item><!-- 自己想要的背景 --> <item name="android:backgroundDimEnabled">false</item><!-- 模糊 --> </style>