I finally figured out a solution for my problem.
I’m using the post
method of the View, which will be executed only after the view measuring and layouting, this way getWidth()
and getHeight()
returns the actual width and height.
Here’s the code sample:
mImage.post(new Runnable() {
@Override
public void run() {
mImage.setImageBitmap(loadBitmapFromView(mImage));
}
});
Hope it also helps someone else 🙂