Erel B4X founder Staff member Licensed User Longtime User Oct 13, 2010 #1 Basic4android includes two special numeric units which are helpful when you create graphics or dynamic layouts and you want to support devices with different scales and dimensions. dip DIP - Density Independent Pixel. Dip values are written related to the default scale, which is 160 DPI (not DIP ) - Dots Per Inch. At runtime these values are scaled based on the device scale. For example: Code: Copy Button1.Width = 100dip This button "physical" size will be the same whether the user device screen is a high resolution device or a low resolution device. Writing 'dip' value is almost always preferred over writing absolute position values. %x, %y Percentage of the activity's width and height respectively (Activity is similar to Form). For example: Code: Copy Button1.Width = 50%x Button1.Height = 25%y This button width will always be half the width of the activity and the height is quarter of the activity height. The percentage units are useful for tabular layouts and to make sure that your layout or graphics always fit (especially with orientation changes). And some code: The saved image:
Basic4android includes two special numeric units which are helpful when you create graphics or dynamic layouts and you want to support devices with different scales and dimensions. dip DIP - Density Independent Pixel. Dip values are written related to the default scale, which is 160 DPI (not DIP ) - Dots Per Inch. At runtime these values are scaled based on the device scale. For example: Code: Copy Button1.Width = 100dip This button "physical" size will be the same whether the user device screen is a high resolution device or a low resolution device. Writing 'dip' value is almost always preferred over writing absolute position values. %x, %y Percentage of the activity's width and height respectively (Activity is similar to Form). For example: Code: Copy Button1.Width = 50%x Button1.Height = 25%y This button width will always be half the width of the activity and the height is quarter of the activity height. The percentage units are useful for tabular layouts and to make sure that your layout or graphics always fit (especially with orientation changes). And some code: The saved image:
JTmartins Active Member Licensed User Longtime User Nov 25, 2015 #2 Is dip de default B4A unit ? I mean, if we have Code: Copy ImageView1.Width=63 (wich throws a compiler warning) is it the same as if we have Code: Copy ImageView1.Width=63dip ? Thanks. Upvote 0
Is dip de default B4A unit ? I mean, if we have Code: Copy ImageView1.Width=63 (wich throws a compiler warning) is it the same as if we have Code: Copy ImageView1.Width=63dip ? Thanks.
Informatix Expert Licensed User Longtime User Nov 25, 2015 #3 JTmartins said: Code: Copy ImageView1.Width=63 Click to expand... Without dip or %, the number is the amount of pixels. Under Android, this unit is of no use most of the time, hence the warning. Upvote 0
JTmartins said: Code: Copy ImageView1.Width=63 Click to expand... Without dip or %, the number is the amount of pixels. Under Android, this unit is of no use most of the time, hence the warning.
JTmartins Active Member Licensed User Longtime User Nov 25, 2015 #4 Clarified. Many thanks informatix. Upvote 0