peacemaker Expert Licensed User Longtime User Apr 28, 2024 #1 HI, All The project is attached: the same code for B4J and B4A. At start the objects are OK at 0.0 coords. Under Windows B4J compilation works ideally (object moving along the grid), but under Android - objects are not fit a bit, if to move both objects and try to fit the circles. Why ? Attachments TempDownload.png 22.7 KB · Views: 573 b4xVectEdit_v0.15.zip b4xVectEdit_v0.15.zip 14.4 KB · Views: 372 TempDownload.png 24.4 KB · Views: 487 Last edited: Apr 28, 2024
HI, All The project is attached: the same code for B4J and B4A. At start the objects are OK at 0.0 coords. Under Windows B4J compilation works ideally (object moving along the grid), but under Android - objects are not fit a bit, if to move both objects and try to fit the circles. Why ?
Erel B4X founder Staff member Licensed User Longtime User Apr 28, 2024 #2 1. Better to apply the grid after the boundaries are set: Code: mRoot.Left = ApplyGrid(Max(0, Min(mRoot.Parent.Width - mRoot.Width, mRoot.Left + X - DownX))) mRoot.Top = ApplyGrid(Max(0, Min(mRoot.Parent.Height - mRoot.Height, mRoot.Top + Y - DownY))) 2. The issue is probably related to the AutoScaleAll in the layout. It will cause the views size to slightly change. Remove it. Upvote 0
1. Better to apply the grid after the boundaries are set: Code: mRoot.Left = ApplyGrid(Max(0, Min(mRoot.Parent.Width - mRoot.Width, mRoot.Left + X - DownX))) mRoot.Top = ApplyGrid(Max(0, Min(mRoot.Parent.Height - mRoot.Height, mRoot.Top + Y - DownY))) 2. The issue is probably related to the AutoScaleAll in the layout. It will cause the views size to slightly change. Remove it.
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #3 Thanks, Erel. But AutoScaleAll does not fully help. Last edited: Apr 28, 2024 Upvote 0
klaus Expert Licensed User Longtime User Apr 28, 2024 #4 Works as expected on my Samsung Galaxy S1 and my Samsung Galay tablet Tab S6. Attachments 1714318511706.png 18.4 KB · Views: 434 Upvote 0
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #5 klaus said: Works as expected on my Samsung Click to expand... Tks for test, Klaus. But check on PC - it's ideally fit at any position - if to fit the circles. But not under Android. I also use Samsung. Attachments TempDownload.png 10 KB · Views: 426 TempDownload.png 9 KB · Views: 362 TempDownload.png 10 KB · Views: 413 Last edited: Apr 28, 2024 Upvote 0
klaus said: Works as expected on my Samsung Click to expand... Tks for test, Klaus. But check on PC - it's ideally fit at any position - if to fit the circles. But not under Android. I also use Samsung.
klaus Expert Licensed User Longtime User Apr 28, 2024 #6 With B4J I get also this !? It is the same as in B4A. Upvote 0
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #7 B4X: Private GridSize As Int = 5dip B4J log is 5 each step of the grid. But B4A is logging as 7. Upvote 0
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #8 Ha ! B4X: Private GridSize As Int = 5 'solved, if without dip Upvote 0
klaus Expert Licensed User Longtime User Apr 28, 2024 #9 I used the project from post #5 as it is and I logged the GridSize, it is 15 on my smartphone with a scale of 3. AutoScaleAll commented or not has no influence. To me, removing dip sounds very strange, because this would mean a different behavior on devices with same physical dimensions but different pixel scales. Upvote 0
I used the project from post #5 as it is and I logged the GridSize, it is 15 on my smartphone with a scale of 3. AutoScaleAll commented or not has no influence. To me, removing dip sounds very strange, because this would mean a different behavior on devices with same physical dimensions but different pixel scales.
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #10 If GridSize As Int = 5 without dip, but all other classes variables are with dip and the grid works OK on 2 phones + emulator: If all without dip: Upvote 0
If GridSize As Int = 5 without dip, but all other classes variables are with dip and the grid works OK on 2 phones + emulator: If all without dip:
klaus Expert Licensed User Longtime User Apr 28, 2024 #11 For me, it does not fit on the circles either in B4J nor B4A. But anyway, it is your project. If it fits your requirements its OK. Upvote 0
For me, it does not fit on the circles either in B4J nor B4A. But anyway, it is your project. If it fits your requirements its OK.
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #12 Yes, maybe not ideal within the screen, but the topic is about the cross-platformity. I'm just try to make to be the fully same at 2 platforms. Upvote 0
Yes, maybe not ideal within the screen, but the topic is about the cross-platformity. I'm just try to make to be the fully same at 2 platforms.
klaus Expert Licensed User Longtime User Apr 28, 2024 #13 peacemaker said: I'm just try to make to be the fully same at 2 platforms. Click to expand... To me, this means dip values for B4A. A same physical point, in B4A, will be displayed almost the same physical size on any Android device. Without dip values a point could be one half or one third of the size of a point in B4J. Dip values have no effect in B4J. But, again, this is just my opinion. But, I do not understand why it works on my devices and not on yours. Are we really using exactly the same project ? Upvote 0
peacemaker said: I'm just try to make to be the fully same at 2 platforms. Click to expand... To me, this means dip values for B4A. A same physical point, in B4A, will be displayed almost the same physical size on any Android device. Without dip values a point could be one half or one third of the size of a point in B4J. Dip values have no effect in B4J. But, again, this is just my opinion. But, I do not understand why it works on my devices and not on yours. Are we really using exactly the same project ?
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #14 It works, but the grid step and the scale are different comparing to the B4J. Is it OK ? I guessed, if the code is the same at both systems, so the scale should be same, isn't it ? But scales of each object are different on PC and Android. Step of 5dip is logged as 5 and 7 at PC and Android. Upvote 0
It works, but the grid step and the scale are different comparing to the B4J. Is it OK ? I guessed, if the code is the same at both systems, so the scale should be same, isn't it ? But scales of each object are different on PC and Android. Step of 5dip is logged as 5 and 7 at PC and Android.
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #15 Hmm, wait, if 5dip grid and the layout without "AutoScaleAll" - seems, is got OK... Last edited: Apr 28, 2024 Upvote 0
klaus Expert Licensed User Longtime User Apr 28, 2024 #16 What is the scale of your Android device ? If its 1, of course it works as you expect it. Upvote 0
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #17 klaus said: scale of your Android device Click to expand... GetDeviceLayoutValues.Scale = 2.8125 Upvote 0
klaus Expert Licensed User Longtime User Apr 28, 2024 #18 peacemaker said: GetDeviceLayoutValues.Scale = 2.8125 Click to expand... What device do you have ? Mine is 3 What do you get with: B4X: Log("GridSize = " & GridSize) Log(GetDeviceLayoutValues.Scale) Log(xui.Scale) I get: GridSize = 15 3 3 Which is coherent. AutoScaleAll has no effect, commented or uncommented. Upvote 0
peacemaker said: GetDeviceLayoutValues.Scale = 2.8125 Click to expand... What device do you have ? Mine is 3 What do you get with: B4X: Log("GridSize = " & GridSize) Log(GetDeviceLayoutValues.Scale) Log(xui.Scale) I get: GridSize = 15 3 3 Which is coherent. AutoScaleAll has no effect, commented or uncommented.
peacemaker Expert Licensed User Longtime User Apr 28, 2024 #19 klaus said: Log("GridSize = " & GridSize) Log(GetDeviceLayoutValues.Scale) Log(xui.Scale) Click to expand... *** Service (starter) Create *** ** Service (starter) Start ** ** Activity (main) Create (first time) ** *** mainpage: B4XPage_Created GridSize = 14 2.8125 2.8125 Click to expand... Upvote 0
klaus said: Log("GridSize = " & GridSize) Log(GetDeviceLayoutValues.Scale) Log(xui.Scale) Click to expand... *** Service (starter) Create *** ** Service (starter) Start ** ** Activity (main) Create (first time) ** *** mainpage: B4XPage_Created GridSize = 14 2.8125 2.8125 Click to expand...