Hi!
Designing some buttons in a row and wanting them to use the full screen width I got some problems.
See aia and screenshot of AI_Companion.
My problem is that the value of the green btn.width attribute set in designer mode seems to be not effected by setting a new value to it with blocks.
With the btn.text attribute no problems.
Can anybody give some clarification?
Also I had some problems with the screensize attribute, which shows other figures than the specs of the device(s) In this link screen_size I read about CSS. So I may find out myself this problem. But if anybody can explain a bit, I would appreciate that very much!
Thank you.
I expect that when I set the screen_width to a calculated value I will extract that value when I use "get btn_width" as a block.
And not the value I gave it in the designer mode.
As you see the read out value stays at 264 instead of the expected 240.
My advice is to not try to target a specific device based upon its given specifications.
Using the AI2 blocks of screen height and width (along with a clock timer - I see you didn't use one - to give the device time to catch up with itself), will be a more reliable method for sizing components on any given screen.
The Designer is an approximation. If your app uses the Fixed Sizing setting you might get the response you expect, however using Responsive sizing works like this http://ai2.appinventor.mit.edu/reference/other/responsiveDesign.html . Contrary to what many App Inventor developers believe, setting to Responsive Sizing does not automatically set the app to make full use of the device screen. What you see is an approximation (actually a pretty good one) created to avoid having a set of images, buttons etc. for multiple screen sizes (as is required whilst using the professional Android Studio. Responsive sizing was intended as a simplification and compromise easily used by nascent developers. Make sure you read the section 3,
Thank you Tim and Steve,
My intention is to make btns and lbls of a size which is calculated from the device height and width to avoid distortion of the design.
I used the same method as discribed in the tutorial which Steve linked me to.
My problem is I can not "trust" the value of the green get btn.width:
When I calculate and set the first button, I cannot set the second button width to the "green attribute btn1_width"!
Instead I have to use a local variable which I used to set the width of btn1
So a work around is keeping a variable alive with the current chosen widths and heigths for later use in the initialization procedure. This work around is ok for my app, but I have to test it on other devices.
@TIMAI2, your revised version is excellent in its simpleness. I'll use this in future.
My problem has in this case nothing to do with buttons, but everything with assigning values. Specially values of properties of components.
My first lesson about strange behaviour with assigning was when I learned of linked-lists in AI2 from @ChrisWard, @ABG and @Juan_Antonio .
With lists, one should use "set list to copy-list" instead of "set list to get list". See other topic
Now I learn another lesson with an assignment out of a component property e.g. "green block Button1.Text".
But this time I think its a real bug.
When you change this revision2 to the case with changing the text property instead of the width, everything works as expected. To my idea there is something wrong with this width property.
See my revision 2 as you have time:
Well chaps, this has to be one of the best Forum Topics - an excellent example and description by TimAI2 and Han_AppInv taking the time to fully understand the solution.