# ohos-viewbadger **Repository Path**: HarmonyOS-tpc/ohos-viewbadger ## Basic Information - **Project Name**: ohos-viewbadger - **Description**: A simple text label view that can be applied as a "badge" to any given component created dynamically at runtime without having to cater for it in layout. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-15 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-textview **Tags**: None ## README # ohos-viewbadger ohos-viewbadger : A simple text label view that can be applied as a "badge" to any given component created dynamically at runtime without having to cater for it in layout. # ohos-viewbadger includes : * Supports "badge" to any given Component created dynamically at runtime without having to cater for it in layout. # Usage Instructions The following core classes are the essential interface to ohos-viewbadger : BadgeView: The entry point for using ViewBadger. BadgeView is intended to be instantiated "badge" on given component at runtime rather than included in XML layouts. ``` public class BadgeView extends Text ``` LogUtil: LogUtil is intended to be use for add log messages. ``` public class LogUtil ``` The steps to initialize the BadgeView and example : ``` public void onStart(Intent intent) { super.onStart(intent); context = getContext(); LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_CONTENT); myLayout.setLayoutConfig(config); myLayout.setPadding(Constants.MAGIC_32, Constants.MAGIC_32, Constants.MAGIC_32, Constants.MAGIC_32); ShapeElement element = new ShapeElement(); element.setShape(ShapeElement.RECTANGLE); element.setRgbColor(new RgbColor(Constants.MAGIC_204, Constants.MAGIC_204, 0)); myLayout.setBackground(element); Image image = new Image(this); image.setPixelMap(ResourceTable.Media_ic_launcher_round); myLayout.addComponent(image); BadgeView badgeView = new BadgeView(context, image); badgeView.setText(text); badgeView.setTextColor(color); badgeView.setTextSize(textSize); badgeView.show(); myLayout.addComponent(badgeView); super.setUIContent(myLayout); } ``` # Installation Instructions 1. For using viewbadger module in sample application, add below dependencies in "entry" module to generate hap : Modify entry build.gradle as below : ``` dependencies { implementation project(':viewbadger') } ``` 2. For using viewbadger in separate application, make sure to add the "viewbadger.har" in entry libs folder as mentioned below : Modify entry build.gradle as below : ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) } ``` 3. For using viewbadger from a remote repository in separate application, add the below dependencies : Modify entry build.gradle as below : ``` dependencies { implementation 'io.openharmony.tpc.thirdlib:ohos-viewbadger:1.0.1' } ``` # License ``` Author: Jeff Gilfelt The code in this project is licensed under the Apache Software License 2.0.
Copyright (c) 2011 readyState Software Ltd. ```