# badgebutton **Repository Path**: archermind-ti/badgebutton ## Basic Information - **Project Name**: badgebutton - **Description**: No description available - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-11-14 - **Last Updated**: 2021-12-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BadgeButton 一个带有徽标(数字,小红点)的按钮的组件 ![badgebutton](screenshot.png) ## 安装方式 ### local ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) implementation project(':library') testCompile 'junit:junit:4.12' ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' } ``` ### Gradle ``` allprojects{ repositories{ mavenCentral() } } implementation "com.gitee.archermind-ti:BadgeButton:1.0.0-beta" ``` ## Usage **XML** ``` xml ``` **JAVA** ``` private void setSelectedList(int i) { int count = directionalLayout.getChildCount(); for (int a = 0; a < count; a++) { BadgeButton component = (BadgeButton) directionalLayout.getComponentAt(a); if (a == i) { component.setSelected(true); component.setTextColor(Color.RED); } else { component.setSelected(false); component.setTextColor(Color.BLACK); } ColorStateList colorStateList = new ColorStateList(); colorStateList.addSelectColor(Color.RED.getValue(), 0Xaaaaaa); BadgeButton badgeButton= component; Element element = badgeButton.getAroundElements()[1]; ViewUtils.setElementColor(element, colorStateList.getColorForState(badgeButton.isSelected())); } } ``` ## License ``` Copyright 2016 czy1121 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```