Is there any way to change the center of a ImageView to rotate?
Without changing the size.
Without changing the size.
ok I'll check.Depending on the exact effect you are trying to achieve, you could probably use Informatix's Animation Plus library to rotate the image view:
https://www.b4x.com/android/forum/threads/lib-animationplus.21313/
Sub Animate(view As View, Degree As Float, Duration As Long)
Dim jo As JavaObject = view
jo.RunMethodJO("animate", Null).RunMethodJO("rotationY", Array(Degree)).RunMethodJO("setDuration", Array(Duration)).RunMethodJO("start", Null)
End Sub
Animate(yourview, 360.0F, 5000)
Do you mean allow it to rotate around a point that is not the default point which is the centre of the imageview ?Is there any way to change the center of a ImageView to rotate?
Exactly.Do you mean allow it to rotate around a point that is not the default point which is the centre of the imageview ?
ie, rotate around the top left corner for example.
#if java
import javafx.scene.control.*;
import javafx.scene.image.*;
import javafx.scene.transform.Rotate;
private static Rotate rotation = new Rotate();
public static void setRotatePoint(ImageView n,Double angle,Double x,Double y){
// clear transforms
n.getTransforms().clear();
//rotation
rotation = new Rotate(angle,x,y);
// add rotation to the imageview
n.getTransforms().add(rotation);
}
#end if
??.RunMethod("setRotatePoint",Array(imgv,30.0,50.0,75.0))
This sample code does what you want
Just call it like normal inline codeB4X:#if java import javafx.scene.control.*; import javafx.scene.image.*; import javafx.scene.transform.Rotate; private static Rotate rotation = new Rotate(); public static void setRotatePoint(ImageView n,Double angle,Double x,Double y){ // clear transforms n.getTransforms().clear(); //rotation rotation = new Rotate(angle,x,y); // add rotation to the imageview n.getTransforms().add(rotation); } #end if
the params are :imageview, angle, xpos, ypos
sowill rotate the imageview 30 degrees clockwise around the point x 50, y 75B4X:??.RunMethod("setRotatePoint",Array(30.0,50.0,75.0))
Hope this helps.
Dim imV as ImageView
imV.Initialize("imV")
MainForm.RootPane.AddNode(imV, 50, 50, -1, -1)
imV.SetImage(fx.LoadImage(File.DirAssets, "moto.png"))
asJavaObject(imV).RunMethod("setRotatePoint",Array(30.0,15.0,15.0))
Sub asJavaObject(j As JavaObject) As JavaObject
Return j
End Sub
This returning an errorYes that's how I call it.
Excellent .. now works perfectlySorry read what you posted again, not so tired now.
it should be
B4X:asJavaObject(Me).RunMethod("setRotatePoint",Array(imv,30.0,15.0,15.0))