• Skip to main content
  • Skip to footer

B4X

Develop Android, iOS and IoT applications

  • Home
  • Products
    • B4A (Android)
    • B4i (iOS)
    • B4J (Desktop)
    • B4R (Arduino)
  • Showcase
  • Store
  • Learn
    • General
    • Guides
    • Video Tutorials
    • Glossary
  • Teach
  • Blog
  • Community
A B C D F G H J M N Q S T U X

All

DIP

DIP – Density Independent Pixel, is a measurement unit, mainly used in Android, that hides the real screen scale. 160 dips is roughly 1 inch on all devices.

Different devices have screens with different scales.
The definition of scale in B4A is <number of pixels per inch> / 160.
It is a common mistake to compare resolutions without the scale value. The width and height are meaningless without it.
For example, a device with resolution of 1200 x 800, scale = 1.0 is a 9” tablet and a device with 1080 x 1794, scale = 2.6 is a 5” phone.
In order to make things simpler, B4X has built-in support for ‘dip’ units. Instead of writing:

Button1.Width = 100 * DeviceScale

We can write:

Button1.Width = 100dip

Note that there is some approximation here. The more accurate screen scale is actually made of two values, one for the horizontal scale and one for the vertical scale. This only matters if you want to build a “ruler app”, and even in that case you will find that the reported accurate values are not always 100% accurate.

A properly built layout shouldn’t target any specific screen size. Use anchors and designer script to build a flexible layout.
Note that the ‘dip’ unit is also available in B4J and B4i, however the scale is always 1.0 as the underlying SDK takes care of handling different scales.

Video tutorial about this topic:

Written by Erel Uziel

Footer

Top

  • Home
  • Products
    • B4A (Android)
    • B4i (iOS)
    • B4J (Desktop)
    • B4R (Arduino)
  • Showcase
  • Store
  • Learn
    • General
    • Guides
    • Video Tutorials
    • Glossary
  • Teach
  • Blog
  • Community

About us

Follow us:

Latest Versions

B4A v13.40 (changelog)
B4i v8.90 (changelog)
B4J v10.3 (changelog)
B4R v4.00 (changelog)

Contact Us

[email protected]
Privacy Policy
Accessibility Statement

Copyright © 2025 · Anywhere Software. Android is a trademark of Google Inc. iOS is a registered trademark of Apple. Arduino is a trademark of Arduino. Java is a trademark of Oracle.