当前位置:网站首页>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 })}}
边栏推荐
猜你喜欢
随机推荐
群组行动控制--自动队列化实现策略
机器学习web服务化实战:一次吐血的服务化之路 (转载非原创)
pytest 之 重运行机制与测试报告
pytest 之 fixture的定义及作用域
pytest 之 fixture参数化
程序员的七夕怎么过?不会是写代码吧
响应式pbootcms模板仪表水表类网站
Unity3d_API_Gyroscope 陀螺仪的接口
RobotFramework 之 用户关键字
NC192 二叉树的后序遍历
pytest 基础认知
JS本地存储 sessionStorage和localStorage
FFmpeg长时间无响应的解决方法
笔试题记录~~
Unity3d_API_GPS_LocationService
浅谈CQRS模式
皮肤资料整理
客户端连接rtsp的步骤
Jetpack Compose——TextField及OutlinedTextField(文本框)的使用
vivo手机上的系统级消息推送平台的架构设计实践