android - View's getWidth() and getHeight() returning 0 -
i have looked @ similar questions , tried solutions did not work me. try take width of imageview, returns 0. here code:
public class mainactivity extends activity { private imageview image1; float centerx,centery; private imageview image2; private boolean isfirstimage = true; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.rotate); image1 = (imageview) findviewbyid(r.id.imageview01); image2 = (imageview) findviewbyid(r.id.imageview02); image2.setvisibility(view.gone); if (isfirstimage) { applyrotation(0, 90); isfirstimage = !isfirstimage; } } private void applyrotation(float start, float end) { centerx=image1.getwidth()/2.0f; centery=image1.getheight()/2.0f; final flip3danimation rotation = new flip3danimation(start, end,centerx , centery); rotation.setduration(500); rotation.setfillafter(true); rotation.setinterpolator(new accelerateinterpolator()); rotation.setanimationlistener(new displaynextview(isfirstimage, image1, image2)); if (isfirstimage) { image1.startanimation(rotation); } else { image2.startanimation(rotation); } } } can me this? thanks
you need use onsizechanged() method.
this called during layout when size of view has changed
Comments
Post a Comment