Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a10655/labelview

Repository files navigation

LabelView

Android Arsenal

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!

Import your project

####Gradle

dependencies {
 compile 'com.lid.labelview:lib:0.1.1'
}

If it doesn't work, please send me a email lid.guan@gmail.com or create an issue.

####Or

Copy LabelView.java into your project.

Create a Label

LabelView extends from TextView so you can treat it as a TextView and use any of its method.

Usage:

LabelView label = new LabelView(this);
label.setText("POP");
label.setBackgroundColor(0xff03a9f4);
label.setTargetView(findViewById(R.id.text), 10, LabelView.Gravity.LEFT_TOP);

setTargetView parameters

setTargetView(findViewById(R.id.text), 10, LabelView.Gravity.LEFT_TOP)
  • The second parameter states the distance between the edge of the bottom view and LabelView (unit dip)

  • The third parameter states the side of where LabelView should appear on the bottom view. (only LEFT_TOP and RIGHT_TOP)

remove label

you can use remove method. eg:

label.remove();

LabelView in BaseAdpter

If you using LabelView in BaseAdpter and reuse of convertView, you have to generate label ID manual. eg:

public View getItemView(int position, View convertView, ViewHolder holder) {
	......
	
 // you have to generate label ID manual
 LabelView label = holder.getView(12345);
 if (label == null) {
 label = new LabelView(this);
 label.setId(12345);
 label.setBackgroundColor(0xffE91E63);
 label.setTargetViewInBaseAdapter(imageView, 138, 10, LabelView.Gravity.LEFT_TOP);
 }
 label.setText(your data);
 return convertView;
}

setTargetViewInBaseAdapter parameters

  • The second parameter means targetView width (unit dip).

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.

About

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!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

  • Java 100.0%

AltStyle によって変換されたページ (->オリジナル) /