首页 > 代码库 > 为ImageView设置背景图片(代码中)

为ImageView设置背景图片(代码中)

仅仅需三行代码

Resources resources = getBaseContext().getResources();   
Drawable imageDrawable = resources.getDrawable(R.drawable.background_image); //图片在drawable文件夹下
mImageView.setBackgroundDrawable(imageDrawable);
<script type="text/javascript"> $(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘
    ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($(‘
  • ‘).text(i)); }; $numbering.fadeIn(1700); }); }); </script>

为ImageView设置背景图片(代码中)