Haitham Elsheshtawy
Haitham Elsheshtawy

Reputation: 11

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

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

Upvotes: -2

Views: 60

Answers (2)

elmorabea
elmorabea

Reputation: 3263

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. enter image description hereenter image description here Place those into containers, namely ViewGroups 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 :)

Upvotes: 0

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.

Upvotes: 0

Related Questions