android - 如何在按钮上添加图像(左)和文本

标签 android button imagebutton

如何在按钮上添加图片(左)和文字?


为了说明:

enter image description here

最佳答案

在你的布局 xml 中使用 android:drawableLeft="@drawable/image"

你也可以从代码中做到这一点

Drawable icon= getContext().getResources().getDrawable( R.drawable.image);
button.setCompoundDrawablesWithIntrinsicBounds( icon, null, null, null );

关于android - 如何在按钮上添加图像(左)和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17258386/

相关文章:

java - Android : why does native_start fails in startNavigating() on Android 2. 3.1 模拟器?

android - 软键盘出现时如何修复底部相对布局?

android - 部署到 Visual Studio 中找不到的 Android 设备

Android:如何创建一个图像和文本都居中的按钮

Android - 在按钮内旋转图像

python - Selenium 按钮点击不起作用

php - 如何使用php、mysql更新数据库

android - RelativeLayout 上面的 LayoutParams

单击时android更改按钮图标

java - 在Java中动态创建从ArrayList到RelativeLayout的ImageButton