set pixelscaling, using screenrect with a scroller

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

set pixelscaling, using screenrect with a scroller

Post by newtronsols » Tue Sep 30, 2014 9:15 pm

I was trying to size my scrolling Android app to fit portrait/landscape using a combination of pixelscaling/setting the scrolling group width. Using the screenrect to calculate. But so far without success.

If I use set the pixelscale [e.g.] to 1.8 I've noticed that I get a 'ghost' remnant of the group to scroll underneath the scroller - which disappears over time. [but i have fixed this by changing the widths of things]

I'm using screenrect for the rect of the scroller, and the formatted width, height of the group for the contentrect of the scroller. This works fine. So I can imagine swapping the height& width values from screenrect I can size the rect of the scroller landscape & portrait.
I've also tried using hoffset for the scroller - but if the horizontal offset is not 0 it seems to stop my scroller working.

I was hoping to get to a formula to use the height & width values from the screenrect (and also whether portrait/landscape) to set the pixelscaling/contentrect etc or even width of the scrolling group of objects [or all] to have a perfect fit.

One problem is that the screenrect is not the full screen size of a real Android phone [so take care using this with emulators!]. This makes it slightly more complex. I 'currently' suspect - 2/10 - if you simply add 48 to the height you get the actual screen size in LC terms.

Personal Lesson:
I have come to realise that when you size an app on Android you need to set stack widths/heights as multiples of screen pixels - so e.g. '360' width is fine.
In my last proper job I briefly worked with a design team who developed the 3d designs of famous cars. To ensure the design complied with Euro regulations they had to check/measure the design - but they proposed a 3d design constraint template which if you dropped the design into the template it would automatically check if it complied with European regs.

So in a similar vein perhaps what is needed in LC are design constraints - e.g. flagged as 'red' if a field encroaches the width of the designated template Android screen. It is a huge waste of time to find that what looks pretty [just like famous car designers find their design may not work within the European regulations] doesn't size/work well using Livecode on the target devices.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: set pixelscaling, using screenrect with a scroller

Post by LCNeil » Fri Oct 03, 2014 1:39 pm

Hi Newtronsols,

The screenRect should always return the resolution of the device that the app is installed on. An example is my Galaxy S3 which has a resolution of 720 x 1280.

When I deploy a LiveCode stack to this devices, and as the pixelScale for this device is 2, the returned screenRect is 0,0,360,640 (which is to be expected). If I then set the pixelScale to 1 and return the screenRect, it comes back at the expected 0,0,720,1280.

Do you have a sample stack, along with the version of LiveCode you are using, that I could test the behaviour you are experiencing?

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.runrev.com
--

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: set pixelscaling, using screenrect with a scroller

Post by newtronsols » Sat Oct 04, 2014 3:40 pm

thanks for the reply - it would take too much time to recreate it all again.

But it consisted of a scroller rect/contentrec that was calculating narrower than the width of the screen. At the time I hadn't realised that screenrect wasn't the complete screen. So I was struggling with an incorrect calculation.

I'll return to it again, later, trying to change the size of a scroller rect/contentrect based on the screenrect +96 pixels and the formatted width/height of the group...i'll be back.

Post Reply

Return to “idea2app and Coding School”