I begun 'learning' graphics in B4i, and found some differences between B4a and B4i based on an iPhone 6:
- There are no 'dip' values in B4i (perhaps not yet ?)
- On my iPhone 6, LayoutValues.Scale returns 1 and LayoutValues.NonnormalizedScale returns 2 which is equivalent to the Android scale value (1dip = 2pixels on the iPhone 6).
- View position and dimension values are 'dip' values in the Designer AND in the code.
In the B4A Designer, position and dimension values are 'dip' values.
But in the code Left, Top, Width and Height values are pixels, in B4i these values are 'dip' values
- The returned values in the Touch event are not pixels but 'dip' values.
- Canvas drawing coordinates and stroke values are 'dip' values and not pixels like in Android.
On my iPhone 6, Canvas.DrawLine(10, 10, 100, 100, Colors.Red, 1)
would be in Android either:
Canvas.DrawLine(20, 20, 200, 200, Colors.Red, 2) in pixels or
Canvas.DrawLine(10dip, 10dip, 100dip, 100dip, Colors.Red, 1dip)in dips.
To draw pixel values on a device with a NonnormalizedScale different to 1 we must devide the 'dip' values by this scale.
Note that all these values are Float variables !
This Android line
Canvas.DrawLine(19, 19, 199, 199, Colors.Red, 1)
must be in iOS with NonnormalizedScale = 2
Canvas.DrawLine(9.5, 9.5, 99.5, 99.5, Colors.Red, 0.5)
- There are no 'dip' values in B4i (perhaps not yet ?)
- On my iPhone 6, LayoutValues.Scale returns 1 and LayoutValues.NonnormalizedScale returns 2 which is equivalent to the Android scale value (1dip = 2pixels on the iPhone 6).
- View position and dimension values are 'dip' values in the Designer AND in the code.
In the B4A Designer, position and dimension values are 'dip' values.
But in the code Left, Top, Width and Height values are pixels, in B4i these values are 'dip' values
- The returned values in the Touch event are not pixels but 'dip' values.
- Canvas drawing coordinates and stroke values are 'dip' values and not pixels like in Android.
On my iPhone 6, Canvas.DrawLine(10, 10, 100, 100, Colors.Red, 1)
would be in Android either:
Canvas.DrawLine(20, 20, 200, 200, Colors.Red, 2) in pixels or
Canvas.DrawLine(10dip, 10dip, 100dip, 100dip, Colors.Red, 1dip)in dips.
To draw pixel values on a device with a NonnormalizedScale different to 1 we must devide the 'dip' values by this scale.
Note that all these values are Float variables !
This Android line
Canvas.DrawLine(19, 19, 199, 199, Colors.Red, 1)
must be in iOS with NonnormalizedScale = 2
Canvas.DrawLine(9.5, 9.5, 99.5, 99.5, Colors.Red, 0.5)
Attachments
Last edited: