From 781a72fa3df0eb9b3de34576649beaf3b24778a5 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Tue, 16 Sep 2025 19:46:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EFAQ=E5=90=8C=E6=BA=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/pages/TextSetOpacity.ets | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 ArkUI/entry/src/main/ets/pages/TextSetOpacity.ets diff --git a/ArkUI/entry/src/main/ets/pages/TextSetOpacity.ets b/ArkUI/entry/src/main/ets/pages/TextSetOpacity.ets new file mode 100644 index 0000000..1dca328 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/TextSetOpacity.ets @@ -0,0 +1,53 @@ +/* +* 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: Text组件设置opacity后,文字颜色在整体透明度基础上叠加了一个透明,应该如何处理 +*/ + +// [Start text_set_opacity] +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Text('你好') + .width(200) + .height(100) + .fontColor(Color.White) + .backgroundColor(Color.Blue) + .fontSize(20) + .textAlign(TextAlign.Center) + .opacity(0.3) + .margin(20) + + Text('你好') + .width(200) + .height(100) + .fontColor(Color.White) + .backgroundColor(Color.Blue) + .fontSize(20) + .textAlign(TextAlign.Center) + .opacity(0.3) + .renderGroup(true) + } + .width('100%') + } + .height('100%') + } +} + +// [End text_set_opacity] \ No newline at end of file -- Gitee