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

Time:08-26

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?

CodePudding user response:

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 'com.intuit.ssp:ssp-android:1.1.0'

For sdp

implementation 'com.intuit.sdp:sdp-android:1.1.0'

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

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiGmMHIk-L5AhUGSGwGHU1WCRsQFnoECAcQAQ&url=https://github.com/intuit/ssp&usg=AOvVaw2ZMN5twdYDhgEafciw5fhV

for sdp

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjb9rqclOL5AhXYzTgGHdP5BZIQFnoECAYQAQ&url=https://github.com/intuit/sdp&usg=AOvVaw21fhKo_QcSaG-J1OIXCylC

  • Related