Skip to content

Commit 6ddd6cf

Browse files
committed
新增设置窗口旋转动画的方法
1 parent b77da92 commit 6ddd6cf

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

README-en.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ easyWindow.setButtonBrightness(@FloatRange(from = -1.0, to = 1.0) float buttonBr
280280
// Set screen orientation for the floating window
281281
easyWindow.setScreenOrientation(int screenOrientation);
282282

283+
// Set the rotation animation of the window (supported on Android 4.3+)
284+
easyWindow.setRotationAnimation(int rotationAnimation);
283285
// Set preferred refresh rate (supported on Android 5.0+)
284286
easyWindow.setPreferredRefreshRate(float preferredRefreshRate);
285287
// Specify which display to show the floating window on (supported on Android 6.0+)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ easyWindow.setButtonBrightness(@FloatRange(from = -1.0, to = 1.0) float buttonBr
286286
// 设置悬浮窗屏幕方向
287287
easyWindow.setScreenOrientation(int screenOrientation);
288288

289+
// 设置窗口旋转动画(Android 4.3 及以上才支持)
290+
easyWindow.setRotationAnimation(int rotationAnimation);
289291
// 设置悬浮窗的刷新率(Android 5.0 及以上才支持)
290292
easyWindow.setPreferredRefreshRate(float preferredRefreshRate);
291293
// 设置悬浮窗在哪个显示屏上显示(Android 6.0 及以上才支持)

library/src/main/java/com/hjq/window/EasyWindow.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,27 @@ public X setScreenOrientation(int screenOrientation) {
557557
return (X) this;
558558
}
559559

560+
/**
561+
* 设置窗口旋转动画
562+
*
563+
* 仅对最顶层不透明的进入和退出窗口设置了 {@link WindowManager.LayoutParams#FLAG_FULLSCREEN} 位且未被其他窗口遮挡的情况有效。
564+
* 其他情况下,将使用默认行为 {@link WindowManager.LayoutParams#ROTATION_ANIMATION_ROTATE}
565+
*
566+
* {@link WindowManager.LayoutParams#ROTATION_ANIMATION_ROTATE}:指定该窗口在旋转后视觉上会旋转进出。
567+
* {@link WindowManager.LayoutParams##ROTATION_ANIMATION_CROSSFADE}:指定该窗口在旋转后会渐入或渐出。
568+
* {@link WindowManager.LayoutParams##ROTATION_ANIMATION_JUMPCUT}:指定该窗口旋转后立即消失或出现。
569+
* {@link WindowManager.LayoutParams##ROTATION_ANIMATION_SEAMLESS}:用来指定无缝旋转模式的值 rotationAnimation ,这类似于跳剪,
570+
* 但如果无法在不暂停屏幕的情况下应用旋转,它会退回到交叉淡入淡出。例如,这非常适合那些不希望取景器内容旋转或淡出(而是希望无缝衔接),
571+
* 但又不想在应用切换场景中出现 ROTATION_ANIMATION_JUMPCUT,无法无缝旋转的相机应用。
572+
*/
573+
public X setRotationAnimation(int rotationAnimation) {
574+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
575+
mWindowParams.rotationAnimation = rotationAnimation;
576+
}
577+
delayUpdate();
578+
return (X) this;
579+
}
580+
560581
/**
561582
* 设置悬浮窗的刷新率(Android 5.0 及以上才支持)
562583
*/

0 commit comments

Comments
 (0)