Android Question How to Rotate a image with 2 Fingers

Alexander Stolte

Expert
Licensed User
Longtime User
Hey,

I have spent all my afternoon in the forum to look for a solution, unfortunately, success.

I use the TouchImageView Lib. and my question is how to rotate a image or a view with my 2 Fingers.

Greetings
 

Alexander Stolte

Expert
Licensed User
Longtime User
I dont know, is that normal?

2017_10_01_02_04_46_1_1.gif


B4X:
Sub Gesture_onDrag(deltaX As Float, deltaY As Float, MotionEvent As Object)
    Log("   onDrag deltaX = " & deltaX & ", deltaY = " & deltaY & ", ev = " & MotionEvent)
    pnlGreen.Left = Max(0, Min(pnlGreen.Left + deltaX, 100%x - pnlGreen.Width))
    pnlGreen.Top = Max(0, Min(pnlGreen.Top + deltaY, 100%y - pnlGreen.Height))
End Sub


Sub Gesture_onRotation(Degrees As Double, MotionEvent As Object)
    Dim jo = pnlGreen As JavaObject
    Dim Angle As Float = Degrees
    jo.RunMethod("setRotation", Array As Object(Angle))
End Sub
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Yes but the rotation does not work:


B4X:
Sub Gesture_onRotation(Degrees As Double, MotionEvent As Object)
    Dim jo = img_emoji As JavaObject
    Dim Angle As Float = Degrees
    jo.RunMethod("setRotation", Array As Object(Angle))
End Sub

Sub Gesture_onDrag(deltaX As Float, deltaY As Float, MotionEvent As Object)
    Log("   onDrag deltaX = " & deltaX & ", deltaY = " & deltaY & ", ev = " & MotionEvent)
    img_emoji.Left = Max(0, Min(img_emoji.Left + deltaX, 100%x - img_emoji.Width))
    img_emoji.Top = Max(0, Min(img_emoji.Top + deltaY, 100%y - img_emoji.Height))
End Sub
 
Last edited:
Upvote 0

eps

Expert
Licensed User
Longtime User
Are you able to give an idea of where your fingers are in relation to the image?

I think Informatix hinted at the possible issues and solution in the thread about the gesture library
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Yes this works fine, but the difficulty is now to zoom and drop.

I found something on Github, I try to wrap it :)
Here is a "shortcut" wrap for the Github project that you are referring to:

1.png



2.png


3.png



1. Extract LibFiles.zip and copy the jar and xml files to your additional library folder
2. Extract DemoRes.zip and copy the folder and its contents to be on the same folder level as that of the B4A project's /Files and /Objects folders.
3. b4aMultiTouch1.zip has the B4A project - see (2) above
4. Take note of the B4A project's manifest file:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

AddApplicationText(<activity
            android:name="com.amitsid.dynamicaddimageview.MainActivity"
            android:label="@string/app_name" >
        </activity>)
 

Attachments

  • LibFiles.zip
    459.5 KB · Views: 332
  • DemoRes.zip
    48.5 KB · Views: 298
  • b4aMultiTouch1.zip
    7.9 KB · Views: 305
Upvote 0
Top