代码拉取完成,页面将自动刷新
本示例介绍在List组件内实现子组件超出容器边缘的布局样式的实现方法。
List组件clip属性默认为true,超出容器边缘的子组件会按照List的布局范围被裁剪。为此,可以在List组件内部添加一个占位的ListItem,以达到预期的布局效果。List占满整个窗口或者不可滚动的情况下,也可以在List外占位,同时设置List的clip属性为false达成同样的效果。
该布局效果多用于头像、列表子项标题等元素的突出显示。
使用说明:
Image($r("app.media.listitem_overflow_io_user_portrait"))
.width(80)
.height(80)
.margin({ top: -50, left: 15 })
List() {
ListItem().height(40).selectable(false) // 占位组件
ListItem() { // 需要超出范围的组件
Image($r("app.media.listitem_overflow_io_user_portrait"))
.width(80)
.height(80)
.margin({ top: -50, left: 15 })
}
...
}
Image($r("app.media.listitem_overflow_io_user_portrait"))
.width(80)
.height(80)
.margin({ top: -50, left: 15 })
Row().height(60) // 占位组件
List() {
ListItem() { // 需要超出范围的组件
Image($r("app.media.listitem_overflow_io_user_portrait"))
.width(80)
.height(80)
.margin({ top: -50, left: 15 })
}
...
}.clip(false)
不涉及
listitemoverflow // har类型
|---AboutMe.ets // 页面布局实现页面
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。