-2

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

5ec20ab0
  • 742
  • 6
  • 15
  • 1
    I 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 Answers2

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.

0

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 :)

elmorabea
  • 3,243
  • 1
  • 14
  • 20