android - How to rotate an ImageView, not just the image, programmatically -



android - How to rotate an ImageView, not just the image, programmatically -

i need rotate imageview using animation, width , height of imageview change.

i have tried using viewpropertyanimator, using view.animate rotates image, , not actual view itself.

i need utilize can work out x , y coords of view after has been rotated, , width , height of it.

i have made test app rotate card image, , have taken pictures layouts visible show mean.

as can see in code, i've tried forcefulness alter width , height in runnable after animation has finished, doesn't work. nor using scalex/scaley seek , alter things.

public class myactivity extends activity implements view.onclicklistener{ relativelayout temp; imageview card; int rotation = 0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_my); card = (imageview) findviewbyid(r.id.card); card.setonclicklistener(this); } @override public void onclick(final view v) { final runnable e1 = new runnable() { public void run() { toast.maketext(myactivity.this, "after1 w="+v.getmeasuredwidth()+" h="+v.getmeasuredheight(), toast.length_short).show(); int w = v.getmeasuredwidth(); int h = v.getmeasuredheight(); v.getlayoutparams().width = h; v.getlayoutparams().height = w; v.setlayoutparams(v.getlayoutparams()); toast.maketext(myactivity.this, "after2 w="+v.getmeasuredwidth()+" h="+v.getmeasuredheight(), toast.length_short).show(); } }; int[] cardcoords = new int[2]; v.getlocationonscreen(cardcoords); toast.maketext(myactivity.this, "x="+cardcoords[0]+" y="+cardcoords[1], toast.length_short).show(); toast.maketext(this, "before w="+v.getmeasuredwidth()+" h="+v.getmeasuredheight(), toast.length_short).show(); rotation = rotation + 90; v.animate(). setduration(1000). rotationby(90); //scalex((float) v.getmeasuredheight() / (float) v.getmeasuredwidth()). //scaley((float) v.getmeasuredheight() / (float) v.getmeasuredwidth()). //.withendaction(e1); }

}

you should looking rotate view, not image then.

rotating view in android

android rotation android-animation android-imageview

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -