1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * 加载基本类型图片 18 */ 19@Entry 20@Component 21struct ImageExample001 { 22 build() { 23 Column() { 24 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { 25 Row() { 26 // 加载png格式图片 27 Image($r('app.media.png')) 28 .width(110).height(110).margin(15) 29 .overlay('png', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 30 // 加载gif格式图片 31 Image($r('app.media.gif')) 32 .width(110).height(110).margin(15) 33 .overlay('gif', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 34 } 35 36 Row() { 37 // 加载svg格式图片 38 Image($r('app.media.svg')) 39 .width(110).height(110).margin(15) 40 .overlay('svg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 41 // 加载jpg格式图片 42 Image($r('app.media.jpg')) 43 .width(110).height(110).margin(15) 44 .overlay('jpg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 45 } 46 } 47 }.height(320).width(360).padding({ right: 10, top: 10 }) 48 } 49} 50