ImageView imageView = findViewById(R.id.imageView); imageView.setMaxHeight(500);
ImageView imageView = new ImageView(this); imageView.setImageResource(R.drawable.image); imageView.setMaxHeight(1000);This code creates a new ImageView widget, sets its image resource to a drawable, and sets the maximum height to 1000 pixels. The setMaxHeight method is part of the android.widget package library.