如何设置图像按钮(Android版)的文本? [英] How to set text of Image Button (Android)?
本文介绍了如何设置图像按钮(Android版)的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Android项目中,我有一个图像按钮的背景设置为某个图像。我想这样设置的图像按钮一些文字。我如何做到这一点/
In my Android project, I've a image button whose background is set to some image. I want so set some text on the image button. How do i do that/
我想设置的文本,因为定位将在项目中使用....
I want to set the text because localization would be used in the project....
推荐答案
这是ImageButton的是不应该有文本,这就是为什么它被称为的ImageButton。
An ImageButton is not supposed to have text, that's why it's called ImageButton.
尝试使用按钮,从TextView的继承和确实有机器人:文本属性
Try to use Button, which inherits from TextView and does have the android:text attribute.
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mail"
android:background="@drawable/btn_selector"/>
有为什么要使用超过按钮的ImageButton什么特别的原因?
Is there any particular reason why you want to use ImageButton over Button?
这篇关于如何设置图像按钮(Android版)的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文