AutoLabelUI


Source link: https://github.com/DavidPizarro/AutoLabelUI

AutoLabelUI

Android library to place labels next to another. If there is not enough space for the next label, it will be added in a new line.

Try out the sample application on Google Play.

Demo

Including in Your Project

Last version is 1.0.1

Just add the following statement in your build.gradle

compile 'com.github.davidpizarro:autolabelui:VERSION' 

You may also add the library as an Android Library to your project. All the library files live in library.

Usage

To add the AutoLabelUI to your layout, add this to your xml

<com.dpizarro.autolabel.library.AutoLabelUI

android:id="@+id/label_view"

android:layout_width="match_parent"

android:layout_height="wrap_content"/>

You can add custom attributes in your xml to customize: drawables, colors, counters, background, behaviors...

<com.dpizarro.autolabel.library.AutoLabelUI

android:id="@+id/label_view"

android:layout_width="match_parent"

android:layout_height="wrap_content"

autolabel:max_labels="10"

autolabel:show_cross="true"

autolabel:text_color="@android:color/white"

autolabel:text_size="@dimen/label_title_size"

autolabel:icon_cross="@drawable/cross"

autolabel:label_background_res="@color/default_background_label"

autolabel:label_padding="@dimen/label_padding"

autolabel:label_clickable="true"/>

Review attrs.xml file to know the list of shapes ready to be used in the library.

This configuration can be also provided programmatically. You can use AutoLabelUI programatically, using the Builder class to set the settings and the desired functionalities:

AutoLabelUI mAutoLabel = (AutoLabelUI) view.findViewById(R.id.label_view);
  AutoLabelUISettings autoLabelUISettings = new AutoLabelUISettings.Builder()

.withMaxLabels(5)

.withIconCross(R.drawable.cross)

.withBackgroundResource(R.drawable.round_corner_background)

.withLabelsClickables(false)

.withShowCross(true)

.withTextColor(android.R.color.holo_red_dark)

.withTextSize(R.dimen.label_title_size)

.withLabelPadding(R.dimen.label_padding)

.build();
  mAutoLabel.setSettings(autoLabelUISettings);

You can set/get values programatically:

mAutoLabel.getBackgroundResource();
 mAutoLabel.getTextColor();
 mAutoLabel.getTextSize();
 mAutoLabel.isLabelsClickables();
 mAutoLabel.setTextColor(android.R.color.holo_red_dark);
 mAutoLabel.setMaxLabels(5);
 mAutoLabel.setBackgroundResource(R.drawable.round_corner_background);
 ...

You can get Label using:

Label label = mAutoLabel.getLabel(1);
 List<Label> labels = mAutoLabel.getLabels();

or remove them all:

mAutoLabel.clear();

To know when you have reached the limit of Labels to add, you will need to implement the onLabelsCompleted interface:

mAutoLabel.setOnLabelsCompletedListener(new AutoLabelUI.OnLabelsCompletedListener() {

  @Override
  public void onLabelsCompleted() {

Toast.makeText(getActivity(), "Completed!", Toast.LENGTH_SHORT).show();

  
}
 
}
);

To know when you have deleted all Labels, you will need to implement the onLabelsEmpty interface:

mAutoLabel.setOnLabelsEmptyListener(new AutoLabelUI.OnLabelsEmptyListener() {

  @Override
  public void onLabelsEmpty() {

Toast.makeText(getActivity(), "EMPTY!", Toast.LENGTH_SHORT).show();

  
}
 
}
);

To know when you have deleted a Label, you will need to implement the onRemoveLabel interface:

mAutoLabel.setOnRemoveLabelListener(new AutoLabelUI.OnRemoveLabelListener() {

  @Override
  public void onRemoveLabel(View view, int position) {

adapter.setItemSelected(position, false);

  
}
 
}
);

To know when you have clicked a Label, you will need to implement the onClickLabel interface:

mAutoLabel.setOnLabelClickListener(new AutoLabelUI.OnLabelClickListener() {

  @Override
  public void onClickLabel(View v) {

Toast.makeText(getActivity(), ((Label) v).getText() , Toast.LENGTH_SHORT).show();

  
}
 
}
);

Or browse the source code of the sample application for a complete example of use.

Contribution

Pull requests are welcome!

I'd like to improve this library with your help! If you've fixed a bug or have a feature you've added, just create a pull request. Issues can be reported on the github issue tracker.

Who's using it

Does your app use AutoLabelUI? If you want to be featured on this list drop me a line.

Author

David Pizarro ( [email protected])

License

Copyright 2015 David Pizarro  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. 

Resources

SunDate_Picker is a library for Persian developers to let users choose date.

Library that implements Snackbars from Google's Material Design documentation.

MaterialList is an Android library created to help all Android developers get the beautiful CardViews that Google shows at its official design specifications.

Provided as a ListView extension, it can receive a list of Cards (stored in a CardList, provided by the library) and show them accordingly to the android style and design patterns.

It also has been developed while keeping extensibility in mind, which means that you are able to create your own card layouts and add them to the CardList without any pain (see examples below).

material-drawer is a custom drawer implementation for Material design apps.

A single EditText instead of a classical form. This Library is a library implementation of flavienlaurent's "Single input form". Very inspired by the Minimal Format Interface.

Implement any form with only one EditText. The idea here is to pack a multiple input form in one field. As a result, the user input is easier and a more fluent process.

Also, TextSwitcher got completely rediscovered to animate the form: title, error message. It's very basic but simple to use.

Android-Iconics is a library to use (almost) any alternative iconfont in your projects. It allows you to add any Android-Iconics compatible typeface-library-addon to your project and you are able to start using that font.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes