Android 代碼裏設置ImageView的src和background

設置ImageView的src:code

image.setImageDrawable(getResources().getDrawable(R.drawable.blackk));
String path=Environment.getExternalStorageDirectory()+File.separator+」test.jpg」;
Bitmap bm = BitmapFactory.decodeFile(path);
image.setImageBitmap(bm);
image.setImageResource(R.drawable.blackk);

設置ImageView的background:get

image.setBackground(getResources().getDrawable(R.drawable.blackk));
image.setBackgroundResource(R.drawable.blackk);
image.setBackgroundDrawable(getResources().getDrawable(R.drawable.blackk));
相關文章
相關標籤/搜索