Home  >  Article  >  Java  >  How to Set the Height and Width of an ImageView Programmatically?

How to Set the Height and Width of an ImageView Programmatically?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-16 22:34:03451browse

How to Set the Height and Width of an ImageView Programmatically?

Programmatic Setting of ImageView Dimensions

Q: How to assign the height and width of an ImageView programmatically?

A: To adjust the height of the ImageView:

imageView.getLayoutParams().height = 20;

Crucial Note: If altering the height after the layout has been established, it's essential to additionally invoke:

imageView.requestLayout();

The above is the detailed content of How to Set the Height and Width of an ImageView Programmatically?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn