Android Question View utils snippets on Android 7

LucaMs

Expert
Licensed User
Longtime User
This code SEEMS to work well:
B4X:
Dim Distance As Float
If 100%x > 100%y Then
    Distance = GetDeviceLayoutValues.Width * GetDeviceLayoutValues.Scale
Else
    Distance = GetDeviceLayoutValues.Height * GetDeviceLayoutValues.Scale
End If
increaseCameraDistance(ImageView1, Distance)

B4X:
Sub increaseCameraDistance(v As View, Distance As Float)
    Dim jo = v As JavaObject
    jo.RunMethod("setCameraDistance", Array(Distance))
End Sub

Tested on the Huawei (smartphone - Android 7) and on an ASUS (tablet - Android 4.4.2)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
This code SEEMS to work well:
Seemed!
tablet.gif
huawei.gif


left = tablet 4.4.2
right = huawei 7

Do not care of the bad gif animations (frame rate - file size - seemingly different speed...).
 

Attachments

  • noa test.zip
    15.3 KB · Views: 262
Last edited:
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
I see.
It seems as if the pivotY is set to 0 or a negative value (could reproduce a similar effect setting it to -Activity.height/2 in a nother phone)

Can you set it to ImageVIew.Height/2 ?

Not sure why it happens only with this phone. It seems as if they have "touched" things internally
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Can you set it to ImageVIew.Height/2 ?
I will certainly try (first I have to wake up and drink a coffee :)); in fact, the above result is very similar to this (and also your answer was...):
https://www.b4x.com/android/forum/threads/nineoldandroids-or-designer.76535/#post-485545

The problem, at that time, was in my code, since I was using the tablet with Android 4.4.2.



P.S. but setting ImageView1.Height to half should be just a test, I think, to see if the problem is this, because I don't want to halve the height of a view depending on the device.
Maybe I should to halve the GetDeviceLayoutValues.Height when I calculate Distance in the code I posted in #21.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
P.S. but setting ImageView1.Height to half should be just a test, I think, to see if the problem is this, because I don't want to halve the height of a view depending on the device.
Maybe I should to halve the GetDeviceLayoutValues.Height when I calculate Distance in the code I posted in #21.
No, because then I would get wrong values in "normal" devices.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I made some changes and the result is surprising (not the one wanted, of course :p:(); shame it is not easy to post animations, plus by two different devices, connected in different ways, it is a nice nuisance (Erel, 512kb are few :().

1) This code is needed because even on "normal" devices the effect was not the wanted one:
B4X:
Dim jo As JavaObject = ImageView1
Dim pos As Float = ImageView1.Height / 2
jo.RunMethod("setPivotY", Array(pos))

2) the code to set the camera distance posted in #21.

Results:
"4.4.2": it seems to be ok.
Huawei: as if a different angle had been used.

tablet.gif
huawei.gif

Tablet ----------------------- Huawei
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Now you have the missing piece for a rotating cube ;)
I did a lot of tests with an app created specifically to study the rotations.

The value of the camera actually changes the distance from the object and the observer, or better, of the camera that observes the image.
Thus, by increasing the distance, the reutations are less perceptible, and by decreasing the distance, it almost seems as if the object rotates upon us.

To have a complete 3D rotation, the pivot point must be able to move also on the Z axis. This is not foreseen.

As soon as I have time I have to look for the code I wrote 15 years ago that I draw vector objects and rotate them around a pitov point in the space of my choice

upload_2018-5-17_12-48-8.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I think that you just need 2 animations, for the image on front and the one on the left (or right, if the cube rotation must be counterclockwise).

Then you change (swap) the bitmaps of the ImageViews when the animation (set of 2 animations) ends.

Using NineOldAndroid it should be "easy" (not on my Huawey, of course :mad:)


P.S. I just read:
To have a complete 3D rotation

I meant, instead, a more simple cube rotation.


P.P.S. which could be a "cube" with... dozens of faces :D (and it would be what I was thinking of doing a long time ago).
 
Last edited:
Upvote 0
Top