1

In our company, design team expect EXACT gap (in pixel) between a TextView and the picture under/above/at the left of the TextView. For example, for a TextView and a picture under it, the gap is calculated from the text's baseline (the bottom of character H) to the top of the picture, for example, 48 dp. In my XML layout file, I use exactly the same value 48 dp for TextView's layout_marginBottom. But, after built, design team capture a screenshot and measure the gap using photoshop, and proved that the gap is not exactly 48 dp, it's actually around 50 dp. I tried includingFontPadding, but also does not work as expect. So, how to specify EXACT gap around text?

wizardlee
  • 881
  • 8
  • 13
  • 5
    Your company's design team has **way too much time** on their hands. – 323go May 19 '14 at 03:32
  • 1
    "it's actually around 50 dp" - within what margin of error? +/- 2 includes 48. – Jonathon Reinhart May 19 '14 at 03:35
  • You can use px but I wouldn't recommend it (and it's considered a bad practice under the official Android design guidelines). Your design team may want things done in exact pixels but in reality that's going to mess up how the screen looks. For example my phone has a 3.7 inch screen with 800x480 (in landscape) - suppose you put a margin of 40px between your text and image so it looks right on my screen. A friend has a 6 inch tablet with 800x480 resolution...think about the actual physical distance when viewed on my phone in comparison to my friend's tablet. It won't look right. – Squonk May 19 '14 at 06:20

1 Answers1

0

Resolution in Photoshop is set in pixels per inch where as the official Google documentation says Android will require images set in dpi.While ppi and dpi and not equivalent.Android documentation describes the relation as px = dp*dpi/160. Supporting Multiple Screens. and Dashboards so you need your own calculation . you can take a look hear convert ppi into dpi

Community
  • 1
  • 1
Tanim reja
  • 2,120
  • 1
  • 16
  • 23