Java tutorial
//package com.java2s; /** * (c) Winterwell Associates Ltd, used under MIT License. This file is background IP. */ import android.view.View; import android.widget.ImageView; public class Main { public static void setSize(View view, int w, int h) { view.setMinimumWidth(w); view.setMinimumHeight(h); if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setAdjustViewBounds(true); iv.setMaxWidth(w); iv.setMaxHeight(h); } } }