Android Tutorial Designer Scripts Tutorial

moster67

Expert
Licensed User
Longtime User
Thank you Erel. I can understand your reasoning and of course I am aware that B4A has evolved a lot over time.

The solution to use a condition could be fine for me. However, would you be able to explain better how to interpret the value ActivitySize returns? I know it returns the approximate activity size measured in inches but how would it relate to resolution (for instance 480x800)? I mean there can be devices which has 4.3 inches with resolution of 480x800 but I guess there may be other phones with same inch-size (4.3) which may use a different resolution. Is there a way to determine resolution based on ActivitySize?

It might be useful from DesignerScript to be able to call GetDeviceLayoutValues and get its values such as scale, height, width...
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
ActivitySize returns the device size measured in inches. This value is more important than the actual resolution.

You should set all the values with 'dip' unit (or percentage). This way the scale doesn't matter.

(If you do want to get the actual resolution then you can get it with 100%x, 100%y, 100dip/100. But you shouldn't).
 

NJDude

Expert
Licensed User
Longtime User
Look at the attached sample, that's what I explained to you in the Chat Room. That's one way of doing it.
 

Attachments

  • SampleForPaul.zip
    415.5 KB · Views: 650
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
I am trying to come to grips with Designer Scripts. In the above example I have removed ListView1 and replaced it with a panel i.e Panel1. I then made Panel1 the parent of ToggleButton1. But when I select the Designer Scripts tab the ToggleButton "disappears" and is no longer visible. How do I get ToggleButton1 to become visible?
 

RonC.

Member
Licensed User
Longtime User
- Landscape (v3.20) - Returns True if the current orientation is landscape.
- Portrait (v3.20) - Returns True if the current orientation is portrait.

Got an error trying to use: If Portrait = True Then

How do you access the variable?

Running version 3.50

Wanted to use this instead of Phone method or comparing Width and Height...
 

pilbazan

Member
Licensed User
Longtime User
Got an error trying to use: If Portrait = True Then

How do you access the variable?

Running version 3.50

Wanted to use this instead of Phone method or comparing Width and Height...

Hi RonC.
If you download the guide.zip of http://www.b4x.com/android/files/guide.zip , inside there are a PDF called B4ACodeSnippets.pdf with a lot of codes examples. One of this is:
2.36 Get the current screen orientation in the code
(posted by Erel). Requires the Reflection library.

I don't know if this or another code of that PDF can help you.
Regards
 

Loris Anoardi

Member
Licensed User
Longtime User
Question abount layout variants:

If the app will run on a device whose layout variant is not defined, which one will be consedered?
Example: i create layout varyant for 320x480 and for 1280x800. What happens if the app will run on a 1024x600 device?
Thanks !
 

Loris Anoardi

Member
Licensed User
Longtime User
Thanks Erel but i can't understand why in large screen devices the autoscaleall doesn't scale at 100%. I created now only a variant (320x480)
I read the tutorial but i don't understand this thing.
See attacched image:

Thank you very much
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Question on Designer Scripts: Is it possible within the designer itself to have some kind of a generator button that will read each view on a layout and give one its coordinates, e.g. top, left, width and height position within the layout that you are working on? This then can be copied and pasted to the code window. I see the balconvertor b4j file and its such a cool app that I'm using, but then its outside the b4a.

#just a thought.
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi to all,
I have a layout problem to handle

In my app I handle the layout with a single "Script - General" script that works fine on devices with medium / big screen with an exception for 3,5" - 320 x 480 px (165 ppi).

I wrote a script variant (Variant specific script: 320x480,scale=1) thats works fine on 320 x 480 px screens but impact also the "Script - General" script and change the correct position of some views.

Is it possible to make a specific script that runs only on the above screen size and let the Script - General works on all other screen size and resolutions ?
 
Last edited:

JdV

Active Member
Licensed User
Longtime User
Hi

I have noticed on some devices I can see the views being moved into place after the layout has loaded. (The effect is more pronounced when there's a load layout animation.)

Would the following be possible?
- Set all views to invisible
- Load the layout
- Adjust the views into their final position
- Detect when the layout has finished loading
- Set all views to visible

Is there an event fired when the designer script has finished executing?

Regards

Joe
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…