Height width problem

i have a problem . i want to create a square. so i just use following code
blocks (1)

but before i clicking button i got this result

but after i clicked it become square like this

why is this happening when code is same in both

NB:

i am using AI2 offline 6.5 and companion 2.73

Try like this:

image

AppInventor needs a little time to get the Screen properties

You can try lower values for the timerInterval, I got 25ms to work...

1 Like

If width in % then height should also be in %, else keep both in dp.

If one did that then the button would not be square. Why calculate up the percentage height from the width when you already have the height from the percentage width ?

1 Like

It's simply 2x the height % to make square. Button height=15%, Width=30%. I never mixed % with dp.

That relies on the device screen being 2:1 (height:width), try it in landscape where you need to reverse it (width 25% height 50%)

There are thousands of Android devices, with different screen sizes, resolutions and aspect ratios. A procentual setting without knowing the specific dpi (px) values doesn't make sense at all.

@TIMAI2 @Anke That answer was for setting button hgt & wdth on scr initialize event. Btw max phones & tablets are mfgd following standard size parameters hgt 2x of width in portrait and when device is in landscape we can reverse it i.e. wdth 2x of hgt. If we want exact square for a2z android devices then the method provided in blocks is correct👍

My Tablet is 138mm wide by 220mm high, a ratio of 1.59, nowhere near 2. This echoes what has already been said.

1 Like

Oh, 1.59 :face_with_monocle:, That device's manufacturer need to fix that in next upgrade :face_with_diagonal_mouth:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.