美文网首页
RadioButton只显示图标时让图标居中

RadioButton只显示图标时让图标居中

作者: Gs1993 | 来源:发表于2017-12-11 10:56 被阅读0次

在使用RadioButton实现Tab时,只想显示图标,于是:

<RadioButton
    android:id="@+id/main_bottom_radio_home"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:button="@null"
    android:drawableTop="@drawable/selector_main_tab_home" />

但效果是下图左起第一个,drawableTop导致图标靠上,使用drawableLeft等属性也不会使图标居中显示。


webwxgetmsgimg.jpg

解决方法,加入

android:textSize="0sp"

如:

<RadioButton
    android:id="@+id/main_bottom_radio_home"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:button="@null"
    android:textSize="0sp"
    android:drawableTop="@drawable/selector_main_tab_home" />

上图后面三个就是如此使图标居中显示。

相关文章

网友评论

      本文标题:RadioButton只显示图标时让图标居中

      本文链接:https://www.haomeiwen.com/subject/ndfiixtx.html