使用WindowManager.addView()方法增加的悬浮窗口,
可以通过设置LayoutParams来达到固定屏幕显示方向的目的,如:
private WindowManager.LayoutParams mLp;
private WindowManager mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
private View mFloatView;
...
mLp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; //竖屏
或
mLp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;//横屏
...
mWindowManager.addView(mFloatView, mLp);
addView的时候增加这个属性,可以固定屏幕显示方向