@@ -502,35 +502,6 @@ public X setVerticalWeight(float verticalWeight) {
502502 return (X ) this ;
503503 }
504504
505- /**
506- * 设置挖孔屏下的显示模式
507- *
508- * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}:默认模式
509- * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES}:内容会延伸至屏幕短边的挖孔区域
510- * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER}:内容不会延伸到挖孔区域
511- * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS}:内容会延伸到挖孔区域
512- *
513- * 文档地址:https://developer.android.com/develop/ui/views/layout/display-cutout?hl=zh-cn
514- */
515- public X setLayoutInDisplayCutoutMode (int layoutInDisplayCutoutMode ) {
516- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
517- mWindowParams .layoutInDisplayCutoutMode = layoutInDisplayCutoutMode ;
518- delayUpdate ();
519- }
520- return (X ) this ;
521- }
522-
523- /**
524- * 设置悬浮窗在哪个显示屏上显示
525- */
526- public X setPreferredDisplayModeId (int preferredDisplayModeId ) {
527- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
528- mWindowParams .preferredDisplayModeId = preferredDisplayModeId ;
529- delayUpdate ();
530- }
531- return (X ) this ;
532- }
533-
534505 /**
535506 * 设置悬浮窗标题
536507 */
@@ -574,7 +545,20 @@ public X setButtonBrightness(@FloatRange(from = -1.0, to = 1.0) float buttonBrig
574545 }
575546
576547 /**
577- * 设置悬浮窗的刷新率
548+ * 设置悬浮窗屏幕方向
549+ *
550+ * 自适应:{@link ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
551+ * 横屏:{@link ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}
552+ * 竖屏:{@link ActivityInfo#SCREEN_ORIENTATION_PORTRAIT}
553+ */
554+ public X setScreenOrientation (int screenOrientation ) {
555+ mWindowParams .screenOrientation = screenOrientation ;
556+ delayUpdate ();
557+ return (X ) this ;
558+ }
559+
560+ /**
561+ * 设置悬浮窗的刷新率(Android 5.0 及以上才支持)
578562 */
579563 public X setPreferredRefreshRate (float preferredRefreshRate ) {
580564 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
@@ -585,7 +569,18 @@ public X setPreferredRefreshRate(float preferredRefreshRate) {
585569 }
586570
587571 /**
588- * 设置悬浮窗的颜色模式
572+ * 设置悬浮窗在哪个显示屏上显示(Android 6.0 及以上才支持)
573+ */
574+ public X setPreferredDisplayModeId (int preferredDisplayModeId ) {
575+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
576+ mWindowParams .preferredDisplayModeId = preferredDisplayModeId ;
577+ delayUpdate ();
578+ }
579+ return (X ) this ;
580+ }
581+
582+ /**
583+ * 设置悬浮窗的颜色模式(Android 8.0 及以上才支持)
589584 */
590585 public X setColorMode (int colorMode ) {
591586 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
@@ -596,15 +591,20 @@ public X setColorMode(int colorMode) {
596591 }
597592
598593 /**
599- * 设置悬浮窗屏幕方向
594+ * 设置挖孔屏下的显示模式(Android 9.0 及以上才支持)
600595 *
601- * 自适应:{@link ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
602- * 横屏:{@link ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}
603- * 竖屏:{@link ActivityInfo#SCREEN_ORIENTATION_PORTRAIT}
596+ * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}:默认模式
597+ * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES}:内容会延伸至屏幕短边的挖孔区域
598+ * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER}:内容不会延伸到挖孔区域
599+ * {@link WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS}:内容会延伸到挖孔区域
600+ *
601+ * 文档地址:https://developer.android.com/develop/ui/views/layout/display-cutout?hl=zh-cn
604602 */
605- public X setScreenOrientation (int screenOrientation ) {
606- mWindowParams .screenOrientation = screenOrientation ;
607- delayUpdate ();
603+ public X setLayoutInDisplayCutoutMode (int layoutInDisplayCutoutMode ) {
604+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
605+ mWindowParams .layoutInDisplayCutoutMode = layoutInDisplayCutoutMode ;
606+ delayUpdate ();
607+ }
608608 return (X ) this ;
609609 }
610610
0 commit comments