Why mostly values are multiples of 8 in Android xml?


Why most of the time if we have to create a margin, padding or anything inside xml we use multiples of 8 or 4?

I was trying to know what is the possible reason for this? Why isn’t it an odd number mostly ?


Spacing methods and layout grids define structure, hierarchy, and rhythm in your design. When correctly used, they reduce decision-making and help establish a rational approach to type scales, positioning, sizing, and spacing.

Base Unit

  • The base unit defines what every measurement will be a multiple of.

  • This keeps designs consistent, improves communication with developers, and reduces the number of decisions a designer has to make.

  • The most recommended base unit is 8px because it makes scaling for a wide variety of devices easy and consistent.

  • This is because most screen sizes are divisible by 8 and because 8 is itself an easily divisible number (8/24, 8/42).

Base Unit

On other hand, as Material Design (is a design system – backed by open-source code – that helps teams build high-quality digital experiences.) explained,

  • All components align to an 8dp square baseline grid for mobile, tablet, and desktop.
  • Icons, type, and some elements within components can align to a 4dp grid.

Refer to these articles for more details,

  1. Everything you need to know as a UI designer about spacing & layout grids
  2. 8pt Material Design GUI Templates

Answered By – snishalaka

Leave a Comment