diff --git a/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp index 46472b8a543fac79df14cd36cebacbdc7a26ba6b..dfa75b5e92a8f43820562dfea1ccf13cbb7606ae 100644 --- a/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp @@ -84,6 +84,26 @@ std::optional SliderLayoutAlgorithm::MeasureContent( float width = contentConstraint.selfIdealSize.Width().value_or(contentConstraint.maxSize.Width()); float height = contentConstraint.selfIdealSize.Height().value_or(contentConstraint.maxSize.Height()); + auto layoutPolicy = layoutWrapper->GetLayoutProperty()->GetLayoutPolicyProperty(); + auto widthLayoutPolicy = LayoutCalPolicy::NO_MATCH; + auto heightLayoutPolicy = LayoutCalPolicy::NO_MATCH; + + if (layoutPolicy.has_value()) { + widthLayoutPolicy = layoutPolicy.value().widthLayoutPolicy_.value_or(LayoutCalPolicy::NO_MATCH); + heightLayoutPolicy = layoutPolicy.value().heightLayoutPolicy_.value_or(LayoutCalPolicy::NO_MATCH); + LOGE("test----widthLayoutPolicy: %{public}d, heightLayoutPolicy: %{public}d", widthLayoutPolicy, heightLayoutPolicy); + } + + + if (widthLayoutPolicy == LayoutCalPolicy::MATCH_PARENT) { + width = contentConstraint.parentIdealSize.Width().value(); + LOGE("TEST--width: %{public}f", width); + } + + if (heightLayoutPolicy == LayoutCalPolicy::MATCH_PARENT) { + height = contentConstraint.parentIdealSize.Height().value(); + LOGE("TEST--height: %{public}f", height); + } Axis direction = sliderLayoutProperty->GetDirection().value_or(Axis::HORIZONTAL); if (direction == Axis::HORIZONTAL && GreaterOrEqualToInfinity(width)) { width = static_cast(theme->GetLayoutMaxLength().ConvertToPx()); diff --git a/frameworks/core/components_ng/pattern/slider/slider_pattern.h b/frameworks/core/components_ng/pattern/slider/slider_pattern.h index 23dc3a9f13e09628d008a7e7975d33be1976db15..17c7b762e003a4c211a98c97499b17ad14be344e 100644 --- a/frameworks/core/components_ng/pattern/slider/slider_pattern.h +++ b/frameworks/core/components_ng/pattern/slider/slider_pattern.h @@ -257,10 +257,14 @@ public: void OnFinishEventTipSize(); void CalculateOffset(); void MountToNavigation(RefPtr& tipNode); - void UpdateSliderComponentColor(const Color& color, const SliderColorType sliderColorType, const Gradient& value); void UpdateSliderComponentMedia(); void UpdateSliderComponentString(const bool isShowTips, const std::string& value); + bool IsEnableMatchParent() override + { + LOGE("slider pattern"); + return true; + } private: void OnAttachToFrameNode() override;