仅仅需三行代码:
Resources resources = getBaseContext().getResources();
Drawable imageDrawable = resources.getDrawable(R.drawable.background_image); //图片在drawable文件夹下
mImageView.setBackgroundDrawable(imageDrawable);
时间: 2024-12-28 01:11:39
仅仅需三行代码:
Resources resources = getBaseContext().getResources();
Drawable imageDrawable = resources.getDrawable(R.drawable.background_image); //图片在drawable文件夹下
mImageView.setBackgroundDrawable(imageDrawable);