如何将位图图像设置为按钮背景图像 [英] How to set bitmap image to Button Background Image

查看:137
本文介绍了如何将位图图像设置为按钮背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);    
gridcell.setText("Day 1");    
URL url = new URL("http://172.16.4.29:81/pht/2013/9/18/3027_2013_9_18_12_14_56_b.JPG");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());

如何将位图 bmp图片设置为按钮gridcells背景图片?

How can I set bitmap bmp image to button gridcells background Image?

推荐答案

您可以使用下面的代码来做到这一点..

You can use following code to do that..

BitmapDrawable bdrawable = new BitmapDrawable(context.getResources(),bitmap);

然后用下面的函数设置位图

then just set bitmap with below function

button.setBackground(bdrawable);

这篇关于如何将位图图像设置为按钮背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆