diff --git a/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets b/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets new file mode 100644 index 0000000000000000000000000000000000000000..039d4a3527bb25ed280eee46bc4fd821e6d0dcde --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:如何解决组件消失动画偏移闪烁? +*/ + +// [Start DisappearanceAnimationOffsetFlicker] +@Entry +@ComponentV2 +struct DisappearanceAnimationOffsetFlicker { + @Local isShow: boolean = true; + + build() { + Stack() { + Stack() { + if (this.isShow) { + Row() + .width(100) + .height(100) + .backgroundColor(Color.Red) + .transition(TransitionEffect.OPACITY.animation({ duration: 150 })) + } + } + .width('100%') + .height('100%') + .onClick(() => { + this.isShow = !this.isShow + }) + } + } +} + +// [End DisappearanceAnimationOffsetFlicker] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets b/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ecc76c68b4bfc9e414cefb99763624df1849570 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/XComponentSurfaceRenderFit.ets @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:Surface模式下的XComponent组件在设置RenderFit后如果出现显示异常,该如何调整以获得正确的显示效果 +*/ +// [Start XComponent_Surface_RenderFit] +@Entry +@Component +struct XComponentSurfaceRenderFit { + @State xc_width: number = 500; + @State xc_height: number = 700; + myXComponentController: XComponentController = new XComponentController(); + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { + XComponent({ + id: 'myXComponent_RenderFitSurface', // 当id的字符串中包含"RenderFitSurface"时,可以使RenderFit显示正确。 + type: XComponentType.SURFACE, + controller: this.myXComponentController + }) + .width(this.xc_width) + .height(this.xc_height) + .renderFit(RenderFit.CENTER) + } + .width('100%') + } +} + +// [End XComponent_Surface_RenderFit] \ No newline at end of file