我在我的Android项目中有一个按钮,它包含两行文本,左边是文本,右边是可绘制的。这与以下代码很好地配合使用:
<Button
android:text="Call History"
android:id="@+id/accountCallLogButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/arrow"
android:padding="10sp"
android:background="@drawable/buttconfig"
android:gravity="left|center_vertical">
</Button>字符串资源:
<string name="addCreditButtonText">Add Credit\nOpens in browser</string>这里我的问题是,在字符串资源的第二行中,我想要一个较小的字体大小和斜体字体。
我该如何解决这个问题呢?
发布于 2010-03-04 21:15:10
步骤1:在描述你想要的内容的字符串资源中加入HTML标记(斜体,小字体)
第2步:使用Html.fromHtml()将字符串资源转换为SpannedString
第3步:使用SpannedString在Button上调用setText()
https://stackoverflow.com/questions/2378598
复制相似问题