Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/linger1216/labelview
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!
https://github.com/linger1216/labelview
Last synced: 3 months ago
JSON representation
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!
- Host: GitHub
- URL: https://github.com/linger1216/labelview
- Owner: linger1216
- License: apache-2.0
- Created: 2015-02-13T14:56:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-07-23T00:08:31.000Z (over 2 years ago)
- Last Synced: 2024-05-03T16:58:19.522Z (9 months ago)
- Language: Java
- Homepage:
- Size: 3.86 MB
- Stars: 1,873
- Watchers: 48
- Forks: 356
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- -awesome-android-ui - LabelView - 2.0) | <img src="https://github.com/linger1216/labelview/blob/master/img/img1.png" width="49%"> (Index `(light-weight pages)`)
- awesome-android-ui - LabelView - 2.0) | <img src="https://github.com/linger1216/labelview/blob/master/img/img1.png" width="49%"> (Index `(light-weight pages)`)
- awesome-github-android-ui - labelview - 轻松实现视图之上的标签 (Label)
- awesome-android-ui - LabelView - 2.0) | <img src="https://github.com/linger1216/labelview/blob/master/img/img1.png" width="49%"> (Index)
README
# LabelView
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LabelView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/3/1538)
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!
![](./img/img1.png)
![](./img/img3.png)
# 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
```java
```
## LabelImageView
```
```
## LabelTextView
```
```
# Parameter Description
![](./img/img2.png)
# 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 functionslike as follows:
```java
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
- [shaunidiot](https://github.com/shaunidiot) English ReadMe supported
## License
```
Copyright 2014 linger1216Licensed 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 athttp://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.
```