gpt4 book ai didi

android - 如何将位图图像设置为按钮背景图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:39:45 26 4
gpt4 key购买 nike

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 图像设置为按钮网格单元背景图像?

最佳答案

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

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

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

button.setBackground(bdrawable);

关于android - 如何将位图图像设置为按钮背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18952764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com