╔══════════════════════════════════════════════╗ ^
║ ImageView ╔══════════════╗ ║ |
║ ║ ║ ║ |
║
your xml file :
<ImageView android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image"
android:scaleType="fitXY"
android:adjustViewBounds="true"/>
your java file:
ImageView imageView = (ImageView)findViewById(R.id.imageView);
int width = imageView.getDrawable().getIntrinsicWidth();
int height = imageView.getDrawable().getIntrinsicHeight();
my friend by this u are not getting height of image stored in db.but you are getting view height.for getting height of image u have to create bitmap from db,s image.and than u can fetch height and width of imageview
Post to the UI thread works for me.
final ImageView iv = (ImageView)findViewById(R.id.scaled_image);
iv.post(new Runnable() {
@Override
public void run() {
int width = iv.getMeasuredWidth();
int height = iv.getMeasuredHeight();
}
});
I think you can let the Android OS take care of this for you. Set the scale type on the ImageView to fitXY
and the image it displays will be sized to fit the current size of the view.
<ImageView
android:layout_width="90px"
android:layout_height="60px"
android:scaleType="fitXY" />