I want to load bitmap efficiently, because frequently on 4.0+ android i get OutOfMemoryError
. So i tried to use sample code from android developers page resource "Loading bitmaps efficiently".
However my problem is to get height and width of ImageView, because dont have any constant values to define dimensions.
Code with required fields from developer page.
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight)
Here is my layout:
<RelativeLayout android:layout_width="match_parent"
android:layout_weight="3"
android:layout_height="0px">
<ImageView
android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/image" />
I tried to use image.getHeight()
but that didnt work.