How to create responsive layout for phones with different screen sizes but same density?


I am trying to create a layout suitable for HDPI scree of size 4" and 5.99". But I tried using density qualifier but it did not work as the things would go out of the layout in 4 or seem small in 5 inch screen. How can I avoid it?


I had faced this issue before and I suggest you to use sdp and ssp instead of dp and sp.

You’ll have to add dependency in your gradle script

For ssp

implementation ''

For sdp

implementation ''

Note :Do not use wrap_content for images and buttons while using sdp. If you do, when running in small device, the system will wrap up the image without considering the size of the screen. So use specific sdp for images and buttons.

For tablets, consider creating different layout and for landscape mode in phone, if its not necessary disable the option, or create new layout.

If you want to learn more about ssp and sdp

for ssp

for sdp

Answered By – winstonbrown

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published