update 优化关闭服务;优化悬浮窗位置

This commit is contained in:
gallonyin
2023-05-29 23:31:39 +08:00
parent e7813b21ba
commit 5f8bc3415b
5 changed files with 41 additions and 7 deletions

View File

@@ -170,7 +170,11 @@ class DefaultFloatService : BaseFloatWindow(), View.OnClickListener {
public override fun leftViewOpened(leftView: View) {
val layoutParams = leftView.fl_window_measure_left.layoutParams as FrameLayout.LayoutParams
leftView.fl_window_measure_left.measure(0, 0)
layoutParams.topMargin = params.y - BarUtils.getStatusBarHeight() - (leftView.fl_window_measure_left.measuredHeight / 2 - leftView.iv_logo_left.measuredHeight / 2)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
layoutParams.topMargin = params.y - (leftView.fl_window_measure_left.measuredHeight / 2 - leftView.iv_logo_left.measuredHeight / 2)
} else {
layoutParams.topMargin = params.y - BarUtils.getStatusBarHeight() - (leftView.fl_window_measure_left.measuredHeight / 2 - leftView.iv_logo_left.measuredHeight / 2)
}
leftView.fl_window_measure_left.layoutParams = layoutParams
// ToastUtils.showShort("左边的菜单被打开了")
}
@@ -178,7 +182,11 @@ class DefaultFloatService : BaseFloatWindow(), View.OnClickListener {
public override fun rightViewOpened(rightView: View) {
val layoutParams = rightView.fl_window_measure_right.layoutParams as FrameLayout.LayoutParams
rightView.fl_window_measure_right.measure(0, 0)
layoutParams.topMargin = params.y - BarUtils.getStatusBarHeight() - (rightView.fl_window_measure_right.measuredHeight / 2 - rightView.iv_logo_right.measuredHeight / 2)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
layoutParams.topMargin = params.y - (rightView.fl_window_measure_right.measuredHeight / 2 - rightView.iv_logo_right.measuredHeight / 2)
} else {
layoutParams.topMargin = params.y - BarUtils.getStatusBarHeight() - (rightView.fl_window_measure_right.measuredHeight / 2 - rightView.iv_logo_right.measuredHeight / 2)
}
layoutParams.leftMargin = ScreenUtils.getScreenWidth() - rightView.fl_window_measure_right.measuredWidth
rightView.fl_window_measure_right.layoutParams = layoutParams
// ToastUtils.showShort("右边的菜单被打开了")