
个人主页→VON
收录专栏→鸿蒙开发小型案例总结
基础语法部分会发布于github 和 gitee上面(暂未发布)

在鸿蒙(HarmonyOS)开发中,自适应伸缩是指应用程序能够根据不同设备的屏幕尺寸、分辨率和形态(如手机、平板、电视)自动调整布局和元素大小,以确保用户界面在各种设备上都能良好地显示和使用。
在鸿蒙(HarmonyOS)开发中,实现圆角效果通常涉及到设置视图(View)或组件(Component)的边框属性。
Text 组件或 Image 组件,可以设置其边框属性,并通过 setCornerRadius 方法设置圆角半径。ShapeElement 来创建更复杂的圆角形状。通过设置不同的圆角半径和形状,可以实现更加个性化的圆角效果。.hap 扩展名。
@Entry
@Component
struct Index {
build() {
Column() {
Column() {
Image($r('app.media.xhs_text_img_02'))
.width('200')
.borderRadius(20)
Text('这段话真的太治愈了!')
.fontColor('#fff')
.fontWeight(600)
.fontSize(12)
.margin({ top: 5, left: -50 ,bottom:10})
// 底部
Row() {
// 头像 昵称
Row() {
Image($r('app.media.tx_01'))
.width(16)
.borderRadius(8)
.margin({left:15,right:5})
Text('解忧日记')
.fontColor('#fff')
.fontSize(10)
}
.layoutWeight(1)
// 点赞图标 点赞数
Row() {
Image($r('app.media.ic_public_favor'))
.fillColor('#fff')
.width(10)
Text('1.4万')
.fontColor('#fff')
.fontSize(10)
.margin({right:15})
}
}
}
.width(200)
.backgroundColor(Color.Black)
.borderRadius(20)
}
.padding(10)
.width('100%')
.height('100%')
.backgroundColor('#ccc')
}
}