个人建设门户网站 如何备案,深圳罗湖医疗集团网站建设,wordpress编辑器不好用,网站建设立项ppt模板列表样式
1、设置内容间距
在列表项之间添加间距#xff0c;可以使用space参数#xff0c;主轴方向
List({ space: 10 }) { … }
2、添加分隔线
分隔线用来将界面元素隔开#xff0c;使单个元素更加容易识别。
startMargin和endMargin属性分别用于设置分隔线距离列表侧…列表样式
1、设置内容间距
在列表项之间添加间距可以使用space参数主轴方向
List({ space: 10 }) { … }
2、添加分隔线
分隔线用来将界面元素隔开使单个元素更加容易识别。
startMargin和endMargin属性分别用于设置分隔线距离列表侧边起始端的距离和距离列表侧边结束端的距离
List() { … } .divider({ strokeWidth: 1, startMargin: 60, endMargin: 10, color: ‘#ffe9f0f0’ })
3、添加滚动条
List() { … } .scrollBar(BarState.Auto)
分组列表
在List组件中使用ListItemGroup对项目进行分组可以构建二维列表
1、简单应用
Component struct ContactsList { …
Builder itemHead(text: string) { // 列表分组的头部组件对应联系人分组A、B等位置的组件 Text(text) .fontSize(20) .backgroundColor(‘#fff1f3f5’) .width(‘100%’) .padding(5) }
build() { List() { ListItemGroup({ header: this.itemHead(‘A’) }) { // 循环渲染分组A的ListItem … } …
ListItemGroup({ header: this.itemHead(‘B’) }) { // 循环渲染分组B的ListItem … } … }
} }
2、循环应用
class Contact {name: string;icon: Resource;constructor(name: string, icon: Resource) {this.name name;this.icon icon;}
}Entry
Component
struct Test03 {private contactsGroups: object[] [{title: 景区一,contacts: [new Contact(aa, $r(app.media.m0)),new Contact(bb, $r(app.media.m1)),new Contact(cc, $r(app.media.m2)),],},{title: 景区2,contacts: [new Contact(dd, $r(app.media.m3)),new Contact(ee, $r(app.media.m4)),],},]Builder itemHead(text: string) {Text(text).fontSize(20).backgroundColor(#fff1f3f5).width(100%).padding(5)}build() {Column() {List() {ForEach(this.contactsGroups, (item) {ListItemGroup({ header: this.itemHead(item.title) }) {ForEach(item.contacts, contact {ListItem() {Row() {Image(contact.icon).width(100).height(100).margin(10)Text(contact.name).fontSize(20)}.width(100%).justifyContent(FlexAlign.Start)}}, contact contact.name)}},item item.title)}}.height(100%).width(100%)}
}3、粘性标题
List() {
。。
.sticky(StickyStyle.Header) // 设置吸顶实现粘性标题效果
列表滚动
1、滚动事件监听
onScroll列表滑动时触发返回值scrollOffset为滑动偏移量scrollState为当前滑动状态。 onScrollIndex列表滑动时触发返回值分别为滑动起始位置索引值与滑动结束位置索引值。 onReachStart列表到达起始位置时触发。 onReachEnd列表到底末尾位置时触发。 onScrollStop列表滑动停止时触发。
2、控制滚动位置
当列表项数量庞大用户滚动列表到一定位置时希望快速滚动到列表底部或返回列表顶部。此时可以通过控制滚动位置来实现列表的快速定位
private listScroller: Scroller new Scroller();
Stack({ alignContent: Alignment.BottomEnd }) { // 将listScroller用于初始化List组件的scroller参数完成listScroller与列表的绑定。 List({ space: 20, scroller: this.listScroller }) { … } …
Button() { … } .onClick(() { // 点击按钮时指定跳转位置返回列表顶部 this.listScroller.scrollToIndex(0) }) … }
3、响应滚动位置
许多应用需要监听列表的滚动位置变化并作出响应。例如在联系人列表滚动时如果跨越了不同字母开头的分组则侧边字母索引栏也需要更新到对应的字母位置。
… const alphabets [‘#’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’];
Entry Component struct ContactsList { State selectedIndex: number 0; private listScroller: Scroller new Scroller(); …
build() { Stack({ alignContent: Alignment.End }) { List({ scroller: this.listScroller }) { … } .onScrollIndex((firstIndex: number) { this.selectedIndex firstIndex // 根据列表滚动到的索引值重新计算对应联系人索引栏的位置this.selectedIndex … }) … // 字母表索引组件AlphabetIndexer({ arrayValue: alphabets, selected: 0 }).selected(this.selectedIndex)...
}} }
列表项侧滑
即用户可以通过向左侧滑列表的某一项再点击删除按钮删除消息
ListItem的swipeAction属性可用于实现列表项的左右滑动功能
Entry Component struct MessageList { State messages: object[] [ // 初始化消息列表数据 … ];
Builder itemEnd(index: number) { // 侧滑后尾端出现的组件 Button({ type: ButtonType.Circle }) { Image($r(‘app.media.ic_public_delete_filled’)) .width(20) .height(20) } .onClick(() { this.messages.splice(index, 1); }) … }
build() { … List() { ForEach(this.messages, (item, index) { ListItem() { … } .swipeAction({ end: this.itemEnd.bind(this, index) }) // 设置侧滑属性 }, item item.id.toString()) } … } } 文章转载自: http://www.morning.wfttq.cn.gov.cn.wfttq.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.tmnyj.cn.gov.cn.tmnyj.cn http://www.morning.lpcct.cn.gov.cn.lpcct.cn http://www.morning.hksxq.cn.gov.cn.hksxq.cn http://www.morning.xmnlc.cn.gov.cn.xmnlc.cn http://www.morning.kgphc.cn.gov.cn.kgphc.cn http://www.morning.gfprf.cn.gov.cn.gfprf.cn http://www.morning.ncwgt.cn.gov.cn.ncwgt.cn http://www.morning.wzknt.cn.gov.cn.wzknt.cn http://www.morning.zfhwm.cn.gov.cn.zfhwm.cn http://www.morning.rnfwx.cn.gov.cn.rnfwx.cn http://www.morning.kttbx.cn.gov.cn.kttbx.cn http://www.morning.tfwsk.cn.gov.cn.tfwsk.cn http://www.morning.nlqmp.cn.gov.cn.nlqmp.cn http://www.morning.blfll.cn.gov.cn.blfll.cn http://www.morning.zmpsl.cn.gov.cn.zmpsl.cn http://www.morning.bfcxf.cn.gov.cn.bfcxf.cn http://www.morning.nkjkh.cn.gov.cn.nkjkh.cn http://www.morning.mbmh.cn.gov.cn.mbmh.cn http://www.morning.tfznk.cn.gov.cn.tfznk.cn http://www.morning.twpq.cn.gov.cn.twpq.cn http://www.morning.qbnfc.cn.gov.cn.qbnfc.cn http://www.morning.qkwxp.cn.gov.cn.qkwxp.cn http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.hnrdtz.com.gov.cn.hnrdtz.com http://www.morning.kfhm.cn.gov.cn.kfhm.cn http://www.morning.rpwm.cn.gov.cn.rpwm.cn http://www.morning.chtnr.cn.gov.cn.chtnr.cn http://www.morning.mxcgf.cn.gov.cn.mxcgf.cn http://www.morning.qysnd.cn.gov.cn.qysnd.cn http://www.morning.hgcz.cn.gov.cn.hgcz.cn http://www.morning.hympq.cn.gov.cn.hympq.cn http://www.morning.jlktz.cn.gov.cn.jlktz.cn http://www.morning.gstg.cn.gov.cn.gstg.cn http://www.morning.txmkx.cn.gov.cn.txmkx.cn http://www.morning.mpscg.cn.gov.cn.mpscg.cn http://www.morning.mnjwj.cn.gov.cn.mnjwj.cn http://www.morning.hjrjy.cn.gov.cn.hjrjy.cn http://www.morning.rnnts.cn.gov.cn.rnnts.cn http://www.morning.wtcyz.cn.gov.cn.wtcyz.cn http://www.morning.mxhys.cn.gov.cn.mxhys.cn http://www.morning.mwjwy.cn.gov.cn.mwjwy.cn http://www.morning.llcgz.cn.gov.cn.llcgz.cn http://www.morning.msbmp.cn.gov.cn.msbmp.cn http://www.morning.rzscb.cn.gov.cn.rzscb.cn http://www.morning.dpbgw.cn.gov.cn.dpbgw.cn http://www.morning.mnslh.cn.gov.cn.mnslh.cn http://www.morning.c7496.cn.gov.cn.c7496.cn http://www.morning.xflwq.cn.gov.cn.xflwq.cn http://www.morning.tymnr.cn.gov.cn.tymnr.cn http://www.morning.xwnnp.cn.gov.cn.xwnnp.cn http://www.morning.lzqnj.cn.gov.cn.lzqnj.cn http://www.morning.fxpyt.cn.gov.cn.fxpyt.cn http://www.morning.xkqjw.cn.gov.cn.xkqjw.cn http://www.morning.gghhmi.cn.gov.cn.gghhmi.cn http://www.morning.rrms.cn.gov.cn.rrms.cn http://www.morning.sldrd.cn.gov.cn.sldrd.cn http://www.morning.kndyz.cn.gov.cn.kndyz.cn http://www.morning.wljzr.cn.gov.cn.wljzr.cn http://www.morning.ctbr.cn.gov.cn.ctbr.cn http://www.morning.wdhzk.cn.gov.cn.wdhzk.cn http://www.morning.nfks.cn.gov.cn.nfks.cn http://www.morning.kkjhj.cn.gov.cn.kkjhj.cn http://www.morning.qcztm.cn.gov.cn.qcztm.cn http://www.morning.ztcwp.cn.gov.cn.ztcwp.cn http://www.morning.rblqk.cn.gov.cn.rblqk.cn http://www.morning.smxrx.cn.gov.cn.smxrx.cn http://www.morning.rszt.cn.gov.cn.rszt.cn http://www.morning.ampingdu.com.gov.cn.ampingdu.com http://www.morning.dnpft.cn.gov.cn.dnpft.cn http://www.morning.ymhjb.cn.gov.cn.ymhjb.cn http://www.morning.byywt.cn.gov.cn.byywt.cn http://www.morning.ryqsq.cn.gov.cn.ryqsq.cn http://www.morning.rbbgh.cn.gov.cn.rbbgh.cn http://www.morning.jnhhc.cn.gov.cn.jnhhc.cn http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn http://www.morning.lgmgn.cn.gov.cn.lgmgn.cn http://www.morning.fqmbt.cn.gov.cn.fqmbt.cn http://www.morning.qnbsx.cn.gov.cn.qnbsx.cn