I am designing a layout as per a set of specification. I basically need to give some space between the layout and the android device. Below image is for reference
I am using following site to convert given pixel into dp values AndroidPixelConverter
I am giving px value in xxxhdpi column and getting its respective dp value, which I am placing it in my xml layout.
The primary phones that I am testing on is Samsung S4 and Nexus5
Following are my questions:
Lastly, is the method which I am following the correct one? If no, please guide in the correct way.
P.S: I am looking for pixel perfect layouts across all devices. Is it possible ?
You need to talk to your designer and go about things in a different way. You NEVER want to specify a layout in px like that. It won't scale- a px can be any size. Go back to him and get a dp number instead (a dp is basically 1/160th of an inch). Design the whole thing in dp. Then let the phone itself translate it to px.
If you design in pixels, it will not work. Design in physical dimensions (dp), and let the device translate.
Also, you can't assume the height of the nav bar. It can, and does differ between devices both in terms of dp and px.