Android - How can I create layout as per image attached for different screens?

- 742
- 6
- 15

- 11
- 1
- 2
-
1I think you're going to need to give some more information about the problem you're facing if you want answers – Quinn Aug 24 '18 at 19:23
2 Answers
You must make different designs and use the visibility attribute to change the designs:
RelativeLayout oneLayout = findViewById (R.id.one_view);
RelativeLayout otherLayout = findViewById (R.id.other_view);
oneLayout.setVisibility (View.GONE);
otherLayout.setVisibility (View.VISIBLE);
To know what design to use:
DisplayMetrics metrics = context.getResources().GetDisplayMetrics ();
int height = metrics.heightPixels;
int width = metrics.widthPixels;
int density = metrics.densityDpi;
This way you will know the width and height of the screen. For the design you have chosen, you should read about RelativeLayout and ConstraintLayout.

- 235
- 1
- 10
So there is one option, which is way too sophisticated and going to be fun to implement but could take forever, you draw this on a Canvas
with all sort of paths and whatnot.
Another option is not very clever, but I think will do the trick!
Step 1
Split your background into squares, so that your background is a grid. Split it horizontally and vertically, like the images below.
Place those into containers, namely
ViewGroup
s that split the screen correctly .. maybe using weights or ConstraintLayout
Step 2 You can align your items to the edges of those backgrounds you constructed.
Just an idea :)

- 3,243
- 1
- 14
- 20