当前位置:网站首页>Badge of openharmony container components
Badge of openharmony container components
2022-08-09 14:18:00 【lplj717】
Badge: a new event marker component that provides event information display capabilities on the component
Badge(value: {count: number, position?: BadgePosition, maxCount?: number, style?:BadgeStyle})
count: Set the number of reminder messages
position: Set the display position of the cue point (BadgePosition)
BadgePosition: RightTop (the dot is displayed in the upper right corner), Right (the dot is displayed in the vertical center on the right), Left (the dot is displayed in the vertical center on the left)
maxCount: the maximum number of messages, only maxCount+
style: The Badge component can be styled, and supports setting text color, size, dot color and size (BadgeStyle)
BadgeStyle:
color Text color
fontSize Text size
badgeSize Badge size
BadgeColor badge color
The effect is as shown:
Code:
@[email protected] BadgeT {@State counts: number = [email protected] message: string = 'new'build() {Column() {Flex({ justifyContent: FlexAlign. SpaceAround }) {//Display the number of messages, click to increase the number of messagesBadge({count: this.counts,maxCount: 99,style: { color: 0xffffff, fontSize: 16, badgeSize: 20, badgeColor: Color.Red }}) {Button('message').onClick(() => {this.counts++}).width(100).height(50).backgroundColor(0x317aa)}.width(100).height(50)/ / Display the message in the upper right corner, display the message contentBadge({value: this.message,style: { color: 0xffffff, fontSize: 9, badgeSize: 20, badgeColor: Color.Blue } }) {Text('message').width(80).height(50).fontSize(16).lineHeight(37).borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xf3f4ED)}.width(80).height(50)//Display the message dot on the rightBadge({value: ' ',position: BadgePosition.Right, style: { badgeSize: 6, badgeColor: Color.Red } }) {Text("message").width(90).height(50).fontSize(16).lineHeight(37).borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xf3f4ED)}.width(90).height(50)}}.width('100%').height('100%').margin({ top: 10 })}}
边栏推荐
猜你喜欢
随机推荐
微服务+微信小程序实现社区服务
常用函数
搭建大型分布式服务(二)搭建会员服务
NC40 链表相加(二)
浅谈CQRS模式
企业公众号开通微信支付
行程和用户[阅读理解法]
Spark Sql之union
如何用vs新建Asp.net项目(Web页面)
零基础学习CANoe Panel 设计目录
RobotFramework 之 RF变量与标准库关键字使用
32位机器和64位机器基本数据类型长度
MySQL主从同步原理
Sql之各种Join
Spark GC日志分析
禁止输入(×),按键精灵小程序,快速上手
富媒体在客服IM消息通信中的秒发实践
Jetpack Compose——remember、mutableStateOf、rememberSaveable
gin's middleware and routing grouping
RobotFramework 之 库与关键字