Sometimes, we need to show a label above an ImageView or any other views. Well, LabelView will be able to help you. It's easy to implement as well!

Related tags

Button labelview
Overview

LabelView

Android Arsenal


Sometimes, we need to show a label above an ImageView or any other views. Well, LabelXXView will be able to help you. It's easy to implement as well!

Import your project

Gradle

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Step 2. Add the dependency

dependencies {
	compile 'com.github.linger1216:labelview:v1.1.2'
}

Or Manual

Copy all java files and attr.xml into your project.


Create a Label

put xml code in you layout, like follows.

LabelButtonView

<com.lid.lib.LabelButtonView
    android:id="@+id/labelbutton"
    android:layout_width="200dp"
    android:layout_height="48dp"
    android:background="#03a9f4"
    android:gravity="center"
    android:text="Button"
    android:textColor="#ffffff"
    app:label_backgroundColor="#C2185B"
    app:label_distance="20dp"
    app:label_height="20dp"
    app:label_orientation="RIGHT_TOP"
    app:label_text="HD"
    app:label_textSize="12sp" />

LabelImageView

<com.lid.lib.LabelImageView
    android:id="@+id/image1"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:scaleType="centerCrop"
    android:src="@mipmap/image1"
    app:label_backgroundColor="#C2185B"
    app:label_orientation="LEFT_TOP"
    app:label_text="CHINA" />

LabelTextView

<com.lid.lib.LabelTextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="48dp"
    android:layout_gravity="center"
    android:layout_marginTop="8dp"
    android:background="#212121"
    android:gravity="center"
    android:padding="16dp"
    android:text="TextView"
    android:textColor="#ffffff"
    app:label_backgroundColor="#03A9F4"
    app:label_distance="15dp"
    app:label_orientation="LEFT_TOP"
    app:label_text="POP"
    app:label_textSize="10sp" />

Parameter Description

If you need Label in your custom View

  1. create an new view class extends YourView
  2. use LabelViewHelper as your Member objects
  3. In Constructor function and onDraw function call LabelViewHelper method.
  4. Call the LabelViewHelper method in other functions

like as follows:

public class LabelXXXView extends YourView {
    LabelViewHelper utils;
    public LabelXXXView(Context context) {
        this(context, null);
    }
    public LabelXXXView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
    public LabelXXXView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        utils = new LabelViewHelper(context, attrs, defStyleAttr);
    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        utils.onDraw(canvas, getMeasuredWidth(), getMeasuredHeight());
    }
    public void setLabelHeight(int height) {
        utils.setLabelHeight(this, height);
    }
    public int getLabelHeight() {
        return utils.getLabelHeight();
    }
    public void setLabelDistance(int distance) {
        utils.setLabelDistance(this, distance);
    }
    public int getLabelDistance() {
        return utils.getLabelDistance();
    }
    public boolean isLabelVisual() {
        return utils.isLabelVisual();
    }
    public void setLabelVisual(boolean enable) {
        utils.setLabelVisual(this, enable);
    }
    public int getLabelOrientation() {
        return utils.getLabelOrientation();
    }
    public void setLabelOrientation(int orientation) {
      	utils.setLabelOrientation(this, orientation);
    }
    public int getLabelTextColor() {
        return utils.getLabelTextColor();
    }
    public void setLabelTextColor(int textColor) {
        utils.setLabelTextColor(this, textColor);
    }
    public int getLabelBackgroundColor() {
        return utils.getLabelBackgroundColor();
    }
    public void setLabelBackgroundColor(int backgroundColor) {
      	utils.setLabelBackgroundColor(this, backgroundColor);
    }
    public String getLabelText() {
        return utils.getLabelText();
    }
    public void setLabelText(String text) {
        utils.setLabelText(this, text);
    }
    public int getLabelTextSize() {
        return utils.getLabelTextSize();
    }
    public void setLabelTextSize(int textSize) {
        utils.setLabelTextSize(this, textSize);
    }
}

Thanks

License

Copyright 2014 linger1216

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.
Comments
  • view problem

    view problem

    Hi, after made label for lazy adapter as you can see in the image link the last image have 2 labels which I just made one label like the other image's label ,but after scrolling up and down this happening

    http://s7.postimg.org/evktvm6gb/Untitled.jpg

    opened by d7coders 6
  • multiple lines label

    multiple lines label

    sometimes I want to use multiple lines to setLabelText() in my LabelView but, I got this result , "Already Transferred", with black background color whatsapp image 2016-08-06 at 18 25 09

    thanks 👍

    opened by irsalshabirin 5
  • Problem in Base Adapter

    Problem in Base Adapter

    label.setTargetView(convertView.findViewById(R.id.featured_icon_row_image), 15, LabelView.Gravity.LEFT_TOP);

    on some items it shows perfect label and on some items it show horizontal Label.

    opened by MalikQasimAli 5
  • Curiosity

    Curiosity

    Hy there this is possible?

    public void setLabelText(String text) { utils.setLabelText(this, text); }

    to

    public void setLabelText(CharSequence text) { utils.setLabelText(this, text); }

    opened by uiktiomasfeliz 1
  • Simple Rotate TextView

    Simple Rotate TextView

    /**
     *  Text rotate in TextView
     *
     * @author Li Yujiang
     * @since 2015/8/12
     * Created by IntelliJ IDEA
     */
    public class RotateTextView extends TextView {
        private static final int DEFAULT_DEGREES = 45;
        private int degrees;
    
        public RotateTextView(Context context) {
            this(context, null);
        }
    
        public RotateTextView(Context context, AttributeSet attrs) {
            super(context, attrs, android.R.attr.textViewStyle);
            setGravity(Gravity.CENTER);
            degrees = DEFAULT_DEGREES;
        }
    
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            canvas.save();
            canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
            canvas.rotate(degrees, this.getWidth() / 2f, this.getHeight() / 2f);
            super.onDraw(canvas);
            canvas.restore();
        }
    
        public void setDegrees(int degrees) {
            this.degrees = degrees;
        }
    
        public int getDegrees() {
            return degrees;
        }
    
    }
    
    opened by gzu-liyujiang 1
  • Corrected Grammatical error

    Corrected Grammatical error

    In the "If you need Label in your custom View", section, the first point is written as: "create an new view class extends YourView". This sentence is grammatically incorrect. 'an' is used before a constant which is against the standard grammatical rules. The corrected sentence could be: "create a new view class extends YourView". Thank you.

    opened by RealWorldEdits376W 0
  • Grammatical error

    Grammatical error

    In the "If you need Label in your custom View", section, the first point is written as: "create an new view class extends YourView". This sentence is grammatically incorrect. 'an' is used before a constant which is against the standard grammatical rules. The corrected sentence could be: "create a new view class extends YourView". Thank you.

    opened by RealWorldEdits376W 0
  • How to remove white border around label.

    How to remove white border around label.

    device-2017-07-20-140742 Everything looks very good. I used this lib and I'm good with it. But when my boss said to remove white border around label view. I searched for any method to remove it but could not find. I stuck. Please help

    opened by brije111 5
Releases(v1.1.2)
Owner
Jingwei
Jingwei
Materially inspired widgets and views that expose RxJava bindings.

Rx.Widgets Materially inspired widgets and views. Use ExpandableButtonGroup Add the widget to your view: <io.andref.rx.widgets.ExpandableButtonGro

Andrefio 12 Mar 12, 2018
Material progress circle around any FloatingActionButton. 100% Guidelines.

FABProgressCircle Android library to provide a material progress circle around your FloatingActionButton. This component is compatible with any existe

Jorge Castillo 1.2k Jan 7, 2023
A cute widget of Switch Button for you to create beautiful and friendly UI.

SwitchButton To get a quick preview, you can get Demo apk in Google Play or Directly download. This project provides you a convenient way to use and c

kyleduo 4.6k Dec 31, 2022
A widget you can slide it to open or close something

SlideSwitch About SlideSwitch A button that you can slide on or off How to import into your project Android Studio use gradle. Gradle dependency: Add

Quinn 539 Jul 12, 2022
comtomize view submit button which you use for submit operation or download operation and so on.

This is library project with a custom view that implements concept of Submit Button (https://dribbble.com/shots/1426764-Submit-Button?list=likes&offse

ZhangLei 129 Feb 5, 2021
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

Burhanuddin Rashid 1k Jan 1, 2023
BlackDex is an Android unpack tool, it supports Android 5.0~12 and need not rely to any environment. BlackDex can run on any Android mobile phones or emulators, you can unpack APK File in several seconds.

BlackDex is an Android unpack tool, it supports Android 5.0~12 and need not rely to any environment. BlackDex can run on any Android mobile phones or emulators, you can unpack APK File in several seconds.

null 4.3k Jan 2, 2023
👋 A common toolkit (utils) ⚒️ built to help you further reduce Kotlin boilerplate code and improve development efficiency. Do you think 'kotlin-stdlib' or 'android-ktx' is not sweet enough? You need this! 🍭

Toolkit [ ?? Work in progress ⛏ ?? ??️ ?? ] Snapshot version: repositories { maven("https://s01.oss.sonatype.org/content/repositories/snapshots") }

凛 35 Jul 23, 2022
Socially is a textView which is able to create separate clickable views according to your requirements.

Socially is a textView which is able to create separate clickable views according to your requirements.

Enes Zor 30 Oct 25, 2022
A Simple Android LabelView.

#FlycoLabelView ####中文版 A Simple Android LabelView. ##Demo ##Gradle dependencies{ compile 'com.flyco.labelview:FlycoLabelView_Lib:1.0.2@aar' } ##A

Flyco 883 Nov 13, 2022
Create parallax and any other transformation effects on scrolling android ImageView

Android Parallax Image View Creates effect such as vertical parallax, horizontal parallax etc. on android ImageView when it's being vertically or hori

Aris 164 Dec 7, 2022
With the Help of this libray you can pic image from camera, gallery, it's support image cropping as well and you can pic PDF

FilePicker This project aims to provide an ultimate and flexible image picking from Gallery, Camera and cropping experience as well as PDF picking fro

Raj Pratap Singh Jadon 3 Nov 24, 2022
Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.

Math World is an Android Application specialized in mathematics, where the application includes some sections related to arithmetic, unit conversion, scientific math laws and constants, as well as some mathematical questions that need some intelligence to reach the solution.

null 7 Mar 12, 2022
Com.hhvvg.anytext - An application provides features to modify any TextView in any other applications

AnyText What's this This application provides features to modify any TextView in

null 6 Dec 2, 2022
An easy-to-use Android library that will help you to take screenshots of specif views of your app and save them to external storage (Including API 29 Q+ with Scope Storage)

???? English | ???? Português (pt-br) ???? English: An easy to use Library that will help you to take screenshots ?? of the views in your app Step 1.

Thyago Neves Silvestre 2 Dec 25, 2021
Android app that helps you keep track of the medical supplements you need to take and how you spend your days

Android app that helps you keep track of the medical supplements you need to take and how you spend your days, similar to a bullet journal. It also allows you to reflect on your day, week, year, etc.

Rachelle Hu 4 Nov 10, 2022
ActSwitchAnimTool make the Animation easy to implements, and it compat the version of Android 4.0 or above.

ActSwitchAnimTool As well as we know, Android 5.0 has been support more Animation(just like ViewAnimationUtils~). Maybe some developers can implements

Acropolis 573 Nov 23, 2022
AndroidGradientImageView is a simple imageview which overlays gradient on its content.

AndroidGradientImageView AndroidGradientImageView is a simple imageView which overlays gradient on its content like below: Setup Gradle dependencies {

Sungcheol Kim 216 Nov 18, 2022