微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 在ImageButton中设置文本

我有一个看起来像这样的 ImageButton.
<ImageButton
            android:id="@+id/ImageButton"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_gravity="center"
            android:layout_marginBottom="6px"
            android:layout_marginRight="3px"
            android:layout_toRightOf="@+id/logo"
            android:background="@drawable/button_bg_purple"
            android:scaleType="fitStart"
            android:src="@drawable/ImageButton" />


 ImageButton ImgButton= (ImageButton) this.findViewById(R.id.ImageButton);

现在我需要以编程方式在ImageButton中添加动态文本,我不能使用按钮.
我该怎么做?

提前致谢 …

解决方法

ImageButton不能包含文本:

您可以尝试的选项

1)使用Button而不是ImageButton

2)使用下面的ImageButton和TextView来显示文本

希望这可以帮助

原文地址:https://www.jb51.cc/android/313916.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐