Android Question Adjust for screens with different resolutions

Discussion in 'Android Questions' started by yaniv hanya, Aug 15, 2019.

  1. yaniv hanya

    yaniv hanya Active Member Licensed User

    So far I have developed the app on a 7 inch screen at 1024/600 resolution today I received a new device with screen of the same size but at 1280/720 resolution and the screens I built are too big and out of the screen.
    I thought the designer values were in Deep and that should solve this problem, isn't it?
    Is there a way to arrange it programmatically or just fix the design in the designer?
    And is there a way to worry about it not happening again on another device?
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. emexes

    emexes Well-Known Member Licensed User

    It's not that your existing screens are too big, it is that the aspect ratio has changed, and the scaling calculation seems to trust that you have used anchors in the right and bottom areas of the layout.

    Also, an AutoScaleRate less than 1 (default is 0.3) means that items are not enlarged/moved as much as the screen dimensions have grown, eg, if you change to a device that is twice as large (eg from a 5" display to a 10" display) then your buttons etc will likely only grow in size by 30%, rather than the 100% (double) that you might expect.
    Designer script is usually straightforward. Or instead of using AutoScaleAll, you could do your own scaling to fit the returned LoadLayout() LayoutValues to the device, although if the aspect ratios are different, you'll end up with some blank border on the vertical or horizontal edges. But apparently I am the only person who likes this approach.
    If you only have a couple of layouts to vary, it may well be simpler and quicker to just add another variant for the new aspect ratio, tweak the positions in the new variant, be done within 5 minutes. There is a school of thought that has taken the reasoning more variants = more things to keep updated = more complex, and extrapolated that to multiple variants = bad, except maybe for portrait/landscape. My thought is that if a tool is available and it does the job... go for it.
    Ripper sense of humour you have there :) ... What?? ... Wait, what do you mean, that question wasn't a joke?!?!
    Last edited: Aug 16, 2019
  4. yaniv hanya

    yaniv hanya Active Member Licensed User

    sorry I meant to ask this:
    Is there a way to prevent this from happening again on another device?
  5. klaus

    klaus Expert Licensed User

  6. Erel

    Erel Administrator Staff Member Licensed User

    Stretching the layout is a mistake. The result will look bad. (Imagine a desktop app that is being stretched when the window is resized)
    The correct approach is to use anchors and designer script to customize your specific layout. It is quite simple to do.
    The base layout should be a small layout (4'' phone).
  7. Erel

    Erel Administrator Staff Member Licensed User

    It is a mistake in most types of apps regardless of the aspect ratio. There is no reason for a button to increase its size more than 2cm * 2cm. In most applications there are views that are expected to fill the available space. These views are usually anchored to BOTH sides. If the layout should be static then put it in a panel in the center of the screen.
    Xicu likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice