How to set margin for ImageView in pixels in android java?

check this

int dpValue = 5; // margin in dips
float d = context.getResources().getDisplayMetrics().density;
int margin = (int)(dpValue * d); // margin in pixels

Leave a Comment