ImageView imageView = findViewById(R.id.image_view); imageView.setImageResource(R.drawable.flower); imageView.setAdjustViewBounds(true);
ImageView imageView = findViewById(R.id.profile_pic); imageView.setImageResource(R.drawable.user_profile_pic); imageView.setAdjustViewBounds(true); imageView.setMaxHeight(200); imageView.setMaxWidth(200);In this code, we're setting the image resource of the ImageView to the user's profile picture, and then calling setAdjustViewBounds with a value of true to tell the ImageView to adjust its dimensions based on the size of the image. We're also setting the maximum height and width of the ImageView to 200 pixels, so that it doesn't get too big. The package library for the ImageView class is "android.widget".