IconButton


Source link: https://github.com/pnc/IconButton

IconButton for Android

IconButton is an Android button widget that allows you to center both the button's text and an icon.

Android's stock Button class allows you to assign a Drawable to the left, right, top, or bottom of a button, but it looks bad if you need to have the button fill the screen:

Installation

For Gradle / Android Studio

Make sure you declare the JCenter repository in your project's build.gradle:

repositories {

  jcenter() 
}

Then add a compile-time dependency on this library, adding the dependencies section to build.gradle if it doesn't already exist:

dependencies {

  compile 'com.githang:com-phillipcalvin-iconbutton:1.0.1@aar' 
}

For Old Version

If you're using ADT, clone this repository and import it into your workspace using File - Import. Then add it to your project by right-clicking your project, selecting Properties, then Android, and adding IconButton in the references list at the bottom of the Properties window.

If you're not using ADT, I recommend using this library as a submodule:

git submodule add [email protected]:pnc/IconButton.git

Generate a local.properties for IconButton:

android update project -n IconButton --path IconButton/IconButton

Then reference the library from your own project.properties:

android.library.reference.1=IconButton/IconButton

If you already have library references, change the 1 to the appropriate number.

Usage

In your layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res/your.project.package"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"  <!-- ... -->
 <com.phillipcalvin.iconbutton.IconButton

 android:id="@+id/search"

 android:drawableLeft="@drawable/action_search"

 android:text="@string/search"

 app:iconPadding="10dp" />

The use of app:iconPadding is optional. It allows you to add padding between the drawable and your text.

Change the text your.project.package to your own project's package. You don't have to use LinearLayout, but you do need to make sure to define the namespace definition ( xmlns:app="http://schemas.android.com/apk/res/your.project.package") appears in the root element.

You can assign either a drawableLeft or a drawableRight to the IconButton.

Caveats

IconButton only supports one drawable on the left or right. I'll absolutely accept patches that improve its handling of multiple drawables.

Contributors

Special thanks to:

  • @msdx for significant contributions around Android Studio and Gradle support.
  • @kaushikgopal for adding left and right drawable support

License

Copyright (c) 2012-2015 Phil Calvin and contributors.

Licensed under the Apache License, Version 2.0

Contains modified source from ParcelHelper, also under the Apache License.

Resources

Android Kotlin Starter is a starter project which implements MVP Pattern.

The MSAL library for Android gives your app the ability to begin using the Microsoft Cloud by supporting Microsoft Azure Active Directory and Microsoft Accounts in a converged experience using industry standard OAuth2 and OpenID Connect. The library also supports Azure AD B2C.

Android Architecture Components (AAC) is a new collection of libraries that contains the lifecycle-aware components. It can solve problems with configuration changes, supports data persistence, reduces boilerplate code, helps to prevent memory leaks and simplifies async data loading into your UI. I can’t say that it brings absolutely new approaches for solving these issues, but, finally, we have a formal, single and official direction.

Rx binding of new Android Architecture Component Lifecycle.

Inject automatically your Activities & Fragments, just with a simple annotation.

Give your users a fantastic experience by providing new and exciting features like: P2P, Proximity, Mesh and Offline connectivity.

By integrating the Bridgefy SDK, app developers ensure that payments, messaging, location-sharing, and ride-hailing apps are still available when people don't have access to data.

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