diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp index 6b24ea42fe608c4de95e4a9355dfad3e59cfe1ce..34bf17ee9100166f2aeb3ec438489414f137c28d 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp @@ -1073,6 +1073,28 @@ OffsetF DialogLayoutAlgorithm::AdjustChildPosition( auto keyboardInsert = manager->GetKeyboardInset(); auto childBottom = childOffset.GetY() + childSize.Height() + embeddedDialogOffsetY_ + stackRootDialogOffsetY_; auto paddingBottom = static_cast(GetPaddingBottom()); + + const bool enabletruncate = true; + + // 如果dialog底部在安全区之下 + if(enabletruncate && childBottom > safeAreaInsets_.bottom_.start){ + auto limitPos = std::min(childOffset.GetY(), + static_cast(safeAreaInsets_.top_.Length() + AVOID_LIMIT_PADDING.ConvertToPx())); + childOffset.SetY(childOffset.GetY() - (childBottom - safeAreaInsets_.bottom_.start)); + + // 缩小逻辑 + if(childOffset.GetY() < limitPos){ + resizeFlag_ = true; + dialogChildSize_ = childSize; + if (limitPos - childOffset.GetY() > dialogChildSize_.Height()) { + dialogChildSize_.MinusHeight(dialogChildSize_.Height()); + } else { + dialogChildSize_.MinusHeight(limitPos - childOffset.GetY()); + } + childOffset.SetY(limitPos); + } + } + if (needAvoidKeyboard && keyboardInsert.Length() > 0 && childBottom > (keyboardInsert.start - paddingBottom)) { auto limitPos = std::min(childOffset.GetY(), static_cast(safeAreaInsets_.top_.Length() + AVOID_LIMIT_PADDING.ConvertToPx()));