I would like to set height and width in dp
for ImageView
in android pragmatically.
How can I achieve this?
Set width & height with dp :
imageview.getLayoutParams().height = (int) getResources().getDimension(R.dimen.imageview_height);
imageview.getLayoutParams().width = (int) getResources().getDimension(R.dimen.imageview_width);
In your dimens.xml provide values for the keys :
<dimen name="imageview_width">50dp</dimen>
<dimen name="imageview_height">50dp</dimen>