当前位置:网站首页>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 })}}边栏推荐
猜你喜欢
随机推荐
力扣学习路径
Q_08 更多信息
Counter of openharmony container components
几种常见路由类型及其优先级
面试攻略系列(二)-- 秒杀系统
蓝桥历届真题-跑步锻炼
【瑞吉外卖】day05:增、删、改、查分类以及公共字段自动填充
海康设备获取YV12图像-不用rtsp
TCP三次握手和四次挥手及拥塞控制
处理JSON,fastjson、json-lib简单使用
远程控制软件-向日葵
C#使用cersharp
【面试高频题】可逐步优化的链表高频题
Spark GC日志分析
pytest 之 重运行机制与测试报告
关于做2D游戏时,Canvas边界显示在Game窗口的问题
pyhook3简单应用(1)--实现截图保存功能
RobotFramework 之 资源文件
Spark Sql之join on and和where
面试攻略系列(三)-- 高级开发工程师面试问些啥?





![行程和用户[阅读理解法]](/img/4b/77bba3c488b5410fdec5c3894c7421.png)



