Giter Club home page Giter Club logo

labelview-1's Introduction

LabelView

Android Arsenal

sorry all, because labview has a design problem, so there have some bugs, I'll be re-implemented in the near future. sorry all, because labview has a design problem, so there have some bugs, I'll be re-implemented in the near future. sorry all, because labview has a design problem, so there have some bugs, I'll be re-implemented in the near future.

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 [email protected] 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.

labelview-1's People

Contributors

linger1216 avatar

Watchers

James Cloos avatar Lerist avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.