1 Star 0 Fork 1

Archermind-TI / badgebutton

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

BadgeButton

一个带有徽标(数字,小红点)的按钮的组件

badgebutton

安装方式

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

<ezy.ui.view.BadgeButton
    ohos:text_alignment="center"
    ohos:padding="6vp"
    ohos:height="match_content"
    ohos:width="0"
    ohos:weight="1"
    ohos:element_top="$media:list_1"
    ohos:text="Text"
    ls:badgeText="123"
    ></ezy.ui.view.BadgeButton>

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.

About

No description expand collapse
Java
Apache-2.0
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Java
1
https://gitee.com/archermind-ti/badgebutton.git
git@gitee.com:archermind-ti/badgebutton.git
archermind-ti
badgebutton
badgebutton
master

Search