如何在Android中创建具有fontawesome字符串作为"icon"和普通文本作为标签的按钮?



我正在尝试创建一个按钮与fontawesome字符串作为"图标"和正常文本作为标签在Android

目前我正在使用这个(在dashboard.xml):

<Button
       android:id="@+id/ndc"
       style="?android:attr/borderlessButtonStyle"
       android:layout_width="0dip"
       android:layout_height="wrap_content"
       android:layout_weight="1"
       android:background="@android:color/transparent"
       android:text="@string/icon_ndc"
       android:textColor="#FFFFFF" 
       android:shadowColor="#000000"
       android:shadowDx="1"
       android:shadowDy="1"
       android:shadowRadius="1"
/>

和这个

(在strings.xml中,它是一个不错的图标)
<string name="icon_ndc">&#xf19c;</string>

我如何添加一个标签,必须有不同的大小,颜色等?

可以使用SpannableString作为按钮的文本。这样,您就可以根据字符串内的开始-结束索引设置不同的字体。请参阅

您可以选择使用Iconify库轻松使用字体awesome跨其他小部件和动画!!

最新更新