标签:iconbutton 图文居中的按钮 图文居中的button
本文介绍一下一个小众的开源项目——IconButton。
本文原创,转载请注明出处:
http://blog.csdn.net/maosidiaoxian/article/details/43560209
这是一个老外两年前写的项目,见:https://github.com/pnc/IconButton。它可以使一个Button的图片与文字一起居中,如下图:
以前要实现这种效果却是用一个Layout和一个ImageView一个TextView来实现它的同学,看到这个项目的这一刻,满满的感动有木有?
为实现设计师设计的界面,我对它的扩展如下:
1.扩展了居中策略。原来的IconButton中,是图片、图片与文字的间距和文字一起居中的。我扩展为默认是这三个一起居中,但也可以设置为仅文字居中或者文字与间距居中。
2.增加了IconCheckBox。这主要是为实现下图中的效果:
repositories {
jcenter()
}dependencies {
compile 'com.githang:com-phillipcalvin-iconbutton:2.0.2'
}<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" />Android开源项目——设置图文居中的按钮 IconButton
标签:iconbutton 图文居中的按钮 图文居中的button
原文地址:http://blog.csdn.net/maosidiaoxian/article/details/43560209