Android Question Int To DIP

LordZenzo

Well-Known Member
Licensed User
this simple operation generates an error in the compilation
B4X:
 LS1.Padding=Array (6.7%x ,0dip,0dip,0dip) [\CODE]

in the forum I found this solution
[CODE]
Sub IntToDIP(Integer As Int) As Int 
   Dim DIP As Int
   DIP = Integer * 1dip
   Return DIP
End Sub
[\CODE]
 

LordZenzo

Well-Known Member
Licensed User
no
this is error in the compilation

LS1.Padding=Array(IntToDIP(4%x),0dip,0dip,0dip)
javac 1.8.0_131
src\com\iliad\gilo\main.java:493: error: incompatible types: Object[] cannot be converted to int[]
parent.mostCurrent._ls1.setPadding((int[])(new Object[]{(Object)(_inttodip(anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (4),mostCurrent.activityBA))),(Object)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0))),(Object)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0))),(Object)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0)))}));
 

emexes

Well-Known Member
Licensed User
To have greater precision and avoid the rounding of 1Dip, Erel suggested to work 100dip / 100.
Whilst down in the mud of pedant detail here...

Since DIP's are defined as 160 per inch, I've been using 160DIP / 160 as the conversion factor, which likely cancels out an integer rounding based on the DIP suffix probably being equivalent to the integer operations: * DevicePPI / 160.

On the one hand, we're only talking about being one pixel out; on the other hand, sometimes one pixel errors stand out like a star in the night sky, especially if there's a line of them.
 
Top