ImageBadgeView

Additional

Language
Java
Version
N/A
Created
Feb 19, 2018
Updated
May 6, 2019
Owner
Ivan V (nikartm)
Contributor
Ivan V (nikartm)
1
Activity
Badge
Generate
Download
Source code

Advertising

ImageBadgeView

Library to add ImageView (ImageBadgeView) with a badge like notification count.

Download

Add to gradle root:

buildscript {
    repositories {
        jcenter()
    }
}

Download via Gradle:

implementation 'com.github.nikartm:image-support:1.0.5'

or Maven:

<dependency>
  <groupId>com.github.nikartm</groupId>
  <artifactId>image-support</artifactId>
  <version>1.0.5</version>
  <type>pom</type>
</dependency>

Screenshots

How to use?

Adjust the xml view More examples.:

<ru.nikartm.support.ImageBadgeView
    android:id="@+id/ibv_icon2"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginTop="30dp"
    android:layout_gravity="center"
    android:padding="10dp"
    app:ibv_badgeValue="100"
    app:ibv_badgeTextSize="12sp"
    app:ibv_fixedBadgeRadius="15dp"
    app:ibv_badgeTextStyle="bold"
    app:ibv_badgeTextColor="#ffffff"
    app:ibv_badgeColor="#00ACC1"
    app:ibv_badgeLimitValue="false"
    android:src="@drawable/ic_shopping_cart" />

Or programmatically:

imageBadgeView.setBadgeValue(27)
        .setBadgeOvalAfterFirst(true)
        .setBadgeTextSize(16)
        .setMaxBadgeValue(999)
        .setBadgeTextFont(typeface)
        .setBadgeBackground(getResources().getDrawable(R.drawable.rectangle_rounded))
        .setBadgePosition(BadgePosition.BOTTOM_RIGHT)
        .setBadgeTextStyle(Typeface.NORMAL)
        .setShowCounter(true)
        .setBadgePadding(4);

Change the position of a badge on view:

app:ibv_badgePosition="bottom_right"

Use the custom badge background:

app:ibv_badgeBackground="@drawable/rectangle_rounded"

Example the custom background - rectangle_rounded.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="#ea5444"/>
    <corners android:radius="24dp"/>

    <stroke
        android:width="1dp"
        android:color="#f5f5f5"/>
</shape>

License

Copyright 2018 Ivan Vodyasov

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.