To set the width and height of an ImageView programmatically, you can use the setLayoutParams() method and pass it a LayoutParams object.