Android Question Is it possible to change the size of the screens of the app automatically

Brian Dean

Well-Known Member
Licensed User
Longtime User
The B4A screen will always fit the 'phone screen. My guess, as you are a new member, is that you are wondering how to build a screen layout made up of several views that will look the same on all devices. Here are some tips ...

1. Use the "Designer" that is part of B4X. Look at this link pointing to two videos that will explain the Designer (the second video listed - watch this one first) and how to use "anchors" (the first video listed).

2. At some time you might want to use "dips" to help set up a screen - they are explained here.

3. Sometimes it is useful to use %x and %y. You can use "view.width = 50%x" to make a view half the width of the screen - any device screen.

Designing a layout to fit the 'phone screen is not a problem with most apps. Only now and again do you have to do something clever.
 
Upvote 1

Cableguy

Expert
Licensed User
Longtime User
Do read @klaus booklets, it will save you lots of questions!
 
Upvote 0

Albert Kallal

Active Member
Licensed User
Is it possible to change the size of the screens of the app automatically to the size of screen of the telephone?

There are in some cases perhaps code that "might" be needed. But you find that the concept of anchoring can really help.

So, say we drop two buttons on a form, like this:

1616867489326.png


Kind of looks ok, but when we view how it going to look (hint: the real time fun fun WYSIWYG designer in B4A is VERY cool).

So, you see this:

1616867771551.png

Hum, that's not so great. But, if you anchor the right button, right?

You do this:
1616867878885.png


Then is swaddles all the way to the right like this:

1616868040173.png


Now, that much better.

In fact, that anchoring is also your friend when you rotate the phone.

Take this screen:

1616868357329.png


Ok, now lets rotate the phone. We can pretend that we using a larger + wider phone!

Without one line of code, I get this:

1616868426744.png


How cool is that?

Now, to be fair, the nice comments text box is getting cut off and the delete button moved up.

so , I would/should/will make or like that text box to jump up into that nice sized hole in the middle between the buttons and controls left side and right side (a nice hole exists there - moving up the text box into that space would be REALLY nice touch! Apparently I can do this with designer scripting, or I suppose I could write some code to move it.

(hint: I need to watch Earl's video on using the designer again - it was RELALY good and helped a lot!!). I never used designer scripts - don't know how to use them yet!

Note that in addition to anchoring? The screen and size DOES scale for you.

Just make sure you start out with a smaller size screen and then work you way up.


There is of course limits to this process. So, I don't think say that a well laid out form for a 10 inch tablet will shrink down to a lower 3.5 inch phone.

But screens can be laid out to re-size quite nice.

And I started out with a really small screen for above - it looks like this:

1616868772803.png


So, I kind of "gave up" on this to work for very small screens The above is set to:

1616868830713.png


320? Now that is a very low end phone these days. So I started exceeding the right side, but I had lots of room, since phones tend to have much larger then what the above layout was telling me. I also needed the app like RIGHT NOW!!! - so I put aside this to work on smaller phone resoutions!

So I hope the above gives you some ideas. The size of things will scale, and toss in some creative anchoring? You be in great shape.

Regards,

Albert D. Kallal
Edmonton, Alberta Canada
 
Upvote 0
Top