Android Open Source project--Set the text Center button Iconbutton

Source: Internet
Author: User
Tags jcenter

This article introduces a small audience of open source project--iconbutton.

This article original, reproduced please indicate the source:

http://blog.csdn.net/maosidiaoxian/article/details/43560209

Brief introduction

This is a foreigner wrote the project two years ago, see: Https://github.com/pnc/IconButton. It enables a button's picture to be centered with the text, such as:


Before to achieve this effect is to use a layout and a imageview a textview to achieve its classmate, see this project this moment, full of touched wood there?

To facilitate the use of the project, and to implement other requirements in the project, I fork the project, modify and extend it, and publish it to Jcenter. In addition, the foreigner is really very friendly.

To implement the designer interface, I expanded it as follows:

1. Extended the centering policy. The original Iconbutton, is the picture, the picture and the text spacing and the text center together. I expand to the default is that the three are centered together, but can also be set to text centered or centered on text and spacing.

2. Added Iconcheckbox. This is primarily for the implementation of the effect:

In, the text is centered, and the small arrow is next to it, and the small arrow has a certain spacing from the text. My project address is: Https://github.com/msdx/IconButton. The expanded content is shown in the develop branch.
Using the Android Studio project built with Gradle,The way to use it is simple, first make sure you declare the Jcenter central warehouse in the build.gradle of the root project:
repositories {    jcenter ()}

Then add this dependency in the Build.gradle in the module:
dependencies {    compile ' com.githang:com-phillipcalvin-iconbutton:2.0.2 '}

For eclipse projects, and not built with Gradle, just copy the code or import the project.
Next, just use this Iconbutton or Iconcheckbox in the layout file, and the code is as follows:
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:app= "http// Schemas.android.com/apk/res-auto "    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 iconpadding is the spacing between the picture and the text. Other extensions use the code shown in the app module in the project.

Android Open Source project--Set the text Center button Iconbutton

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.