I have an app with a layout that loads some remote images. When the remote image is being loaded, a clock with 100 forced height is being displayed (i did it overwriting onDraw from imageview), and when the remote image is downloaded and ready to be displayed, the clock dissapears and then the image appears.
It works, but when the image appears did not receive the correct height, it still haves the height of the clock (100).
I dont know why, because when the image is displayed it calls a handler wich refresh the view of the image and the container layout of the image with the new height (365), but it is not working properly.
this is the handler:
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if( ((ImageView)view) != null && resource != null && resource.image != null ){
((ImageView)view).setImageBitmap( resource.image );
view.getLayoutParams().height=height;
((ViewGroup)view.getParent()).getLayoutParams().height=height;
((ImageView)view).invalidate();
((ViewGroup)view.getParent()).invalidate();
((ViewGroup)view.getParent()).refreshDrawableState();
view.invalidate();
}
}
};
the handler is being called, the image is being displayed, the height value on the handler is correct (365), but the image is still being displayed with the height of the clock (100).
Also i must say that if i block the screen and unblock the screen, the image appears with the correct height (365). It seems that there is a problem with invalidate().
Thanks all
Solved
I must reinstanciate the view each time i load the image element:
view = new FocusableImageView( activity );