How would you support different screen sizes?

Technology CommunityCategory: AndroidHow would you support different screen sizes?
VietMX Staff asked 3 years ago
  • Create a flexible layout — The best way to create a responsive layout for different screen sizes is to use ConstraintLayout as the base layout in your UI. ConstraintLayout allows you to specify the position and size for each view according to spatial relationships with other views in the layout. This way, all the views can move and stretch together as the screen size changes.
  • Create stretchable nine-patch bitmaps
  • Avoid hard-coded layout sizes — Use wrap\content or match\parent. Create alternative layouts — The app should provide alternative layouts to optimise the UI design for certain screen sizes. For eg: different UI for tablets
  • Use the smallest width qualifier — For example, you can create a layout named main\activity that’s optimised for handsets and tablets
  • The smallest width qualifier specifies the smallest of the screen’s two sides, regardless of the device’s current orientation, so it’s a simple way to specify the overall screen size available for your layout.