ImageView imageView = findViewById(R.id.image_view); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image); imageView.setImageBitmap(bitmap);
ImageView imageView = findViewById(R.id.image_view); Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/image.jpg"); imageView.setImageBitmap(bitmap);In this example, we are getting an instance of ImageView, decoding the image from a file path using BitmapFactory and setting it to the ImageView using the setImageBitmap method. Both these examples are part of the android.graphics library.