androidandroid-layoutpixel-density

Android:Is it advisable to use dp to specify size of UI elements?


Is using dp alone good enough to ensure that the size of the UI elements will be consistent aross all screen sizes and densities? Or do we have to use Linear Layout's weightSum feature to ensure a more consistent result?


Solution

  • Yes.

    Depending on what you try to accomplish: dp will ensure the same size across screens, and weights (or percent in the android support library) will keep its ratios.