Guidelines in layouts in android studio

32 Views Asked by At

I am new to android studio and android development. I am trying to use guidelines to make my layout adapt to all screen sizes. I am setting the guidelines by the percentage tag.

For eg: Inside my login screen I am creating different guidelines for margin of the parent layout, guidelines for different buttons and textfields, etc instead of giving them a height and a width, to correctly place them.

My idea behind this is that as the screen size of a mobile phone changes (for eg from google pixel 7 to google pixel 1) then the guidelines will automatically adapt to the percentage of the screen, like if I set the left margin guideline to 5% then it will be 5% on both the smartphone screen size, hence giving me a consistent design, for all screen sizes.

Question: Is this approach of mine correct or will it cause my app to lag or like is there any better approach for adaptive and responsive layout?

2

There are 2 best solutions below

0
Ammar On

Consider using this library for responsive design across devices.
Developed by **Intuit**:

https://github.com/intuit/sdp

Responsive Preview

2
Niraj Bhadani On

I think You can try LinearLayout and add padding or margin.