How to get the Dimensions of a Drawable in an ImageView? [duplicate]
Just tried this out and it works for me: int finalHeight, finalWidth; final ImageView iv = (ImageView)findViewById(R.id.scaled_image); final TextView tv = (TextView)findViewById(R.id.size_label); ViewTreeObserver vto = iv.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { // Remove after the first run so it doesn’t fire forever iv.getViewTreeObserver().removeOnPreDrawListener(this); finalHeight = iv.getMeasuredHeight(); finalWidth = iv.getMeasuredWidth(); tv.setText(“Height: ” + finalHeight … Read more