目錄:java
一、引言canvas
二、功能介紹微信
引言佈局
如今不少的APP會有新消息/未接來電/未讀消息/新通知圓球紅點提示,典型的以微信、QQ新消息提示爲例,當微信朋友圈有新的朋友更新/發佈朋友圈消息後,在微信的底部切換卡上會有一個紅色的小圓球紅點,表示有新消息,提示用戶查看。在消息通信類的app中十分實用。post
功能介紹測試
鴻蒙BGABadgeView 徽章組件,主要功能包括:傳入圖片生成徽章,設置文本生成文本徽章,而且每一個徽章都具備拖拽超範圍便可消除,範圍內便可回到原位置。模擬機效果圖以下this
1.圖片徽章:
2.文字徽章:
3.拖動徽章爆炸:
使用時候,直接將其下載,做爲一個har包導入到本身的項目中便可。下面則詳細介紹BGABadgeView 的使用以及開發指南。
BGABadgeView 使用指南
Ø 新建工程, 添加組件Har包依賴
在應用模塊中添加HAR,只須要將verificationcodeview-debug.har複製到entry\libs目錄下便可
Ø 修改配置文件
1. 修改主頁面的佈局文件:
<?xml version="1.0" encoding="utf-8"?> <DependentLayout xmlns:ohos="http://schemas.huawei.com/res/ohos" ohos:height="match_parent" ohos:width="match_parent" ohos:id="$+id:layout1" ohos:orientation="vertical"> <DependentLayout ohos:id="$+id:dependent1" ohos:height="200vp" ohos:width="match_parent"> <com.example.bgabadgecomp_library.BAGDragBadgeImage ohos:top_margin="15vp" ohos:right_margin="10vp" ohos:bottom_margin="10vp" ohos:height="80vp" ohos:width="80vp" ohos:scale_mode="zoom_center" ohos:image_src="$media:avator" ohos:id="$+id:image1" ohos:below="$id:title" ohos:left_margin="30vp"/> <Image ohos:top_margin="15vp" ohos:right_margin="10vp" ohos:bottom_margin="10vp" ohos:height="80vp" ohos:width="80vp" ohos:scale_mode="zoom_center" ohos:image_src="$media:avator" ohos:id="$+id:image2" ohos:end_of="$id:image1" ohos:below="$id:title" ohos:left_margin="10vp"/> </DependentLayout> <Text ohos:left_margin="30vp" ohos:id="$+id:text1" ohos:top_margin="10vp" ohos:right_margin="15vp" ohos:bottom_margin="10vp" ohos:height="40vp" ohos:width="match_parent" ohos:text="測試1"