Layout on iOS differs from Layout on Android

I am getting (remaining) very frustrated with my choice to use Flex and Adobe products for my mobile app. Adobe making SWFLoader an available object in mobile WITHOUT TELLING US IT WON'T WORK IN PRODUCTION cost me a lot of time and money. My last post here was at the beginning of November when I believed I was about ready to deploy my app but I've had to take all this time to re-write it given that SWFLoader was added to the dist just to make it possible for programmers to really go the wrong direction. Sorry to be so annoyed but honestly, this has cost me a lot of money and I don't have the rest of my life to screw around with software that does not do what the vendor says it will do.
In any event, my latest frustration, now that I'm back to being done with all the re-coding aspects of the app, is getting it to lay out on screen properly. On my Android device, I just add the flex component to the screen, find the registration point, center on that and it lays out properly. In iOS, it does not work. Here is an example of laying out a screen with a center registration point.
var xPixels:uint = Capabilities.screenResolutionX;
var yPixels:uint  = Capabilities.screenResolutionY;
                if(xPixels < yPixels) {
                    //phone is tilted and we're measuring the incorrect orientation.
                    //reverse x and y and double them to get proper screen dim.
                    var yPix:uint = xPixels + xPixels;
                    xPixels = yPixels + yPixels;
                    yPixels = yPix;
                //the following will be sure that we've centered the
                //screen.
                xPixels = xPixels / 2;
                yPixels = yPixels / 2;
               this.busyLoader = new LoaderMessageCurtain;
                busyLoader.x = xPixels;
                busyLoader.y = yPixels;               
                enemyViewContainer.addChild(busyLoader);
                loaderShowing = true;
In the above code, busyLoader was created in FlashPro (as all my screens and animations are). It was converted to a Flex component. It has  registration at the center of the screen. On Android, this code causes the screen to lay out properly. On iOS, I'll get the top left corner in the center of the screen. WHY?????????????? WHY, WHY, WHY? I'm sick of it. Can anyone help me understand the voodoo that is going on behind the scenes to actually be done with this project with a professional looking piece of software that behaves as expected on ALL platforms it is touted as being able to be run on?
Notice as well that on Android, I don't have to tell busyLoader what dimensions it is. That's great. However, on iOS, if I don't set the width and height of the component, it will be giant or super small but not properly sized in either case. When I do set the dimensions, the outcome is problematic. Sometimes it fits and sometimes I need to add or subtract an arbitrary number of pixels to get it size properly. Sigh.
Also, I write software on a large monitor. Using the emulators to lay out code is a total waste. If I use the iPhone 4 emulator, for instance, it reports that my screen size is 1900 by 1200. Well, my monitor is 1900 by 1200 but an iPhone is not (it's 960 by 640 if I recall). It does me no good to have an emulator lay out based on my screen size. That too has cost me dearly. No offense and your tools are cool and I hope that I'll be able to solve my frustrations with Flex and continue to use your tools, but why don't you guys try doing what I do before I release software... make sure it works?

The reason the objects have a center registration is because the animator was trying to ensure that the animations work for different screen sizes without changing the length to width ratio of the animations. He drew a black border around the entire stage. On platforms where the screen does not fill the stage properly, the black border shows up at bottom. While I will make sure that he keeps them registered at top left from now on, I don't see why that makes any difference. A center point is a center point and should work as well as any other point on a screen (I would think).
Well the problem is that it requires you to know ahead of time how a particular asset is registered in order to properly layout and position it through code. Display objects are much easier to work with if you can assume they are always registered in their natural top left corner, and should not extend passed the desired width/height (IE. setting a negative x/y value to get a "border"). This allows the developer to know exactly where it should be positioned based on it's measured size, without having to worry about varying registration points.
I'm very interested in your thoughts on the Capabilities.screenResolutionX and Y function. Given that screens are not laying out properly without explicitly setting their size, and I want them to be the size of the screen in question (it's a full-screen mobile app), I have no choice but to call Capabilities.screenResolution X and Y and set myFlexComp.w and h as these values. If there is a better way to do this, please point me toward the resource so I can learn about it.
One should never assume the application fits the entire screen (as you have seen first hand). There are numerous better way to do this. It really depends on how your application is set up.
Here is an example AIR app that shows one possible way these assets can be correctly imported and positioned within your application. If you run the app and resize the window, you will see that the icon will always remain centered and the background will always fill the size of the window (notice how the MainView_background symbol has 9-slice scaling enabled in the fla, which is how the border remains a uniform size regardless of the window size).
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
                                                                              xmlns:views="views.*" width="1024" height="768">
               <fx:Style>
                              @namespace s "library://ns.adobe.com/flex/spark";
                              @namespace views "views.*";
                              views|MainView
                                             backgroundClass: Embed(source="assets.swf", symbol="MainView_background");
                                             iconClass: Embed(source="assets.swf", symbol="MainView_icon");
               </fx:Style>
               <views:MainView top="0" left="0" bottom="0" right="0" />
</s:WindowedApplication>
package views
               import flash.display.DisplayObject;
               import mx.core.IFlexDisplayObject;
               import mx.core.ILayoutElement;
               import mx.core.UIComponent;
                * This class takes 2 styles for a background and icon class. The background is
                * scaled to the size of the component, while the icon is centered within it.
                * I also copied a few utility methods from the MobileSkin to show how the various
                * class formats are supported.
               public class MainView extends UIComponent
                              public function MainView()
                                             super();
                               * Copied from spark.skins.mobile.supportClasses.MobileSkin
                              public static function getElementPreferredHeight(element:Object):Number
                                             if(element is ILayoutElement)
                                                            return ILayoutElement(element).getPreferredBoundsHeight();
                                             else if(element is IFlexDisplayObject)
                                                            return IFlexDisplayObject(element).measuredHeight;
                                             else
                                                            return element.height;
                               * Copied from spark.skins.mobile.supportClasses.MobileSkin
                              public static function getElementPreferredWidth(element:Object):Number
                                             if(element is ILayoutElement)
                                                            return ILayoutElement(element).getPreferredBoundsWidth();
                                             else if(element is IFlexDisplayObject)
                                                            return IFlexDisplayObject(element).measuredWidth;
                                             else
                                                            return element.width;
                               * Copied from spark.skins.mobile.supportClasses.MobileSkin
                              public static function setElementPosition(element:Object, x:Number, y:Number):void
                                             if(element is ILayoutElement)
                                                            ILayoutElement(element).setLayoutBoundsPosition(x, y, false);
                                             else if(element is IFlexDisplayObject)
                                                            IFlexDisplayObject(element).move(x, y);
                                             else
                                                            element.x = x;
                                                            element.y = y;
                               * Copied from spark.skins.mobile.supportClasses.MobileSkin
                              public static function setElementSize(element:Object, width:Number, height:Number):void
                                             if(element is ILayoutElement)
                                                            ILayoutElement(element).setLayoutBoundsSize(width, height, false);
                                             else if(element is IFlexDisplayObject)
                                                            IFlexDisplayObject(element).setActualSize(width, height);
                                             else
                                                            element.width = width;
                                                            element.height = height;
                              private var _background:DisplayObject;
                              private var _icon:DisplayObject;
                              override protected function createChildren():void
                                             super.createChildren();
                                             var bgClass:Class = this.getStyle("backgroundClass") as Class;
                                             if(bgClass != null)
                                                            _background = new bgClass();
                                                            this.addChild(_background);
                                             var iconClass:Class = this.getStyle("iconClass") as Class;
                                             if(iconClass != null)
                                                            _icon = new iconClass();
                                                            this.addChild(_icon);
                              override protected function measure():void
                                             super.measure();
                                             //lets say our prefered dimensions are at least the size of the icon...
                                             if(_icon)
                                                            this.measuredWidth = getElementPreferredWidth(_icon);
                                                            this.measuredHeight = getElementPreferredHeight(_icon);
                                                            trace("this.measuredWidth = " + this.measuredWidth);
                                                            trace("this.measuredHeight = " + this.measuredHeight);
                               * @private
                              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                                             trace("MainView.updateDisplayList(" + unscaledWidth + ", " + unscaledHeight + ")");
                                             super.updateDisplayList(unscaledWidth, unscaledHeight);
                                             //bet let's actually scale the contents to the full size as set by the parent...
                                             if(_background != null)
                                                            setElementSize(_background, unscaledWidth, unscaledHeight);
                                                            setElementPosition(_background, 0, 0);
                                             //and we will center the icon within those bounds...
                                             if(_icon != null)
                                                            var iconWidth:Number = getElementPreferredWidth(_icon);
                                                            var iconHeight:Number = getElementPreferredHeight(_icon);
                                                            var iconX:Number = (unscaledWidth - iconWidth) / 2;
                                                            var iconY:Number = (unscaledHeight - iconHeight) / 2;
                                                            trace("iconWidth = " + iconWidth);
                                                            trace("iconHeight = " + iconHeight);
                                                            trace("iconX = " + iconX);
                                                            trace("iconY = " + iconY);
                                                            setElementPosition(_icon, iconX, iconY);
This methodology uses the appropriate stages in the flex component life-cycle to create, measure, and position its contents.
*note: I was going to attach an example project, but I can't seem to figure out how to add an attachment. Send me a PM if you would like me to email it to you.
*edited a few typos*

Similar Messages

  • Dialog Programing: Output screen layout is different from actaul layout

    Hi,
    I have developed screen layout in SE51 and same is used in my program.Program is working fine but the problem is in column order.I designed layout in SE51 by copying structure from ABAP dictionary and same has been used in my program but output layout column order is completely different from SE51 screen layout.When i check this on Se51,everything is in order.
    My program is referring the same screen number and program.there is only one screen i.e 100.
    How do we fix this problem.
    Regards,

    Looks like, your table settings got changed for the table control on the screen.
    Run your program.
    Now, on the screen you can find out the "Table Settings" in the Top Right corner of the Table control as ICON.
    Press the Icon and it will bring the Table Settings screen.
    In the Current Settings, choose the Basic Settings ... save and close.
    Regards,
    Naimesh Patel

  • Print layout is different from the working view.

    I got two calendars in iCal, marked with red and green. I always make the green ones as the first one on everyday and the red ones as the second. However, when I printed the scheduled month, some red ones were in the upper positions and it looked different from my screen.
    How can I make all the green ones as the first event in the printed version.

    You can make objects visible only on the screen by selecting Object => Presence => Visible (Screen Only). You can do the same for printing by selecting the Visible (Print Only) option.
    Hope this helps,
    Mike

  • Layout Looks Different from Dreamweaver to Email?

    I am currently using Adobe Dreamweaver CS5 to create emails for my work. Last month I started having an issue where the 3 columns I have in the template would look even in Dreamweaver, but when I sent a test email to myself they looked completely off. This past week I have encountered another issue where the cellpadding of the email looks different from Dreamweaver to email. I am new to HTML and coding so it could just be me, but is anyone having a similar problem and if so, is there a way to fix it?

    Nancy-O posted this recently.  You might find it helpful.
    Martin
    http://alt-web.com/Articles/HTML-Emails.shtml
    Achieving consistent results across email clients is not as straightforward as it should be!

  • I was having ios 4.3 and decided to upgrade to ios 5 and in doing so I lost all my apps despite I restored from my earlier back up. The itunes I've backed up is different from the itunes I have used to upgrade-..

    I was having ios 4.3 and decided to upgrade to ios 5 and in doing so I lost all my apps despite I restored from my earlier back up. The itunes I’ve backed up is different from the itunes I have used to upgrade….. I was wondering if I can get back my apps that were purchased using different apple ID (not mine). Since I am in Ethiopia doesn’t even have the chance to buy it again. I have searched it in my computer/c/user/adminstrator….but couldn’t find it. Anyone p/l help

    When I updated my iPhone to IOS 5, I did it from my MB Air, when my iPhone's "home" is my work 27" iMac. I figured I could just download the new OS at home where internet is fast and then sync at office and be done. 
    WRONG!!!  So, like others here, all my apps were "gone."
    Following some of what I read above, I did the following and now all my apps that I purchased in the past are downloading to my 27". 
    In iTunes I went to Purchased, under "Store" in left column of iTunes.
    Then at the bottom of the Purchased screen was something like Download all apps, borrom right (sorry, cant see it now, its downloading all of them).  Once I hit that, I could see all my apps and it looks like they are all coming back.
    Now all I have to do is put them all like I had them before, folders, etc.  That will be a pain BUT at least I have all of them.

  • The last Apple I used was a IIe. Where can I find basic information about what an Ipad will do and how it differs from an Android tablet?

    The last Apple I used was a IIe. Where can I find basic information about what an Ipad will do and how it differs from an Android tablet?
    I am considering purchasing this for my wife who has only had experience with Windows machines.

    Here are a number of possibilities:
    http://ipad.about.com/od/iPad_Guide/a/How-To-Use-The-iPad-Best-Uses.htm
    http://www.macobserver.com/tmo/article/8-important-things-you-can-do-with-an-ipa d
    http://iconlibrary.iconshock.com/tutorials/50-things-you-can-and-cant-do-with-yo ur-new-ipad/
    iPad vs Android:
    http://ipad.about.com/od/ipad_competition/tp/iPad-vs-Android-Which-Tablet-Should -You-Buy.htm
    http://www.cnet.com/topics/tablets/best-tablets/

  • Same itunes library, multiple ios devices from different people?

    before anything, let me tell u that i followed the advice here...
    http://support.apple.com/kb/HT1495?viewlocale=en_US&locale=en_US
    and i lost all 3rd party apps and app data on my dad's ipad.
    we have two ipads at home. the one belonging to my dad was never synced to an itunes library ever! it was set up as new right from the ipad. now, to install ios 7 on it i followed the instructions above and 'made a new library' in my user accound on the mac. my dad doesn't have any user account on our home mac as he never uses the computer at home.
    so then i 'backedup' everything from my dad's ipad to the library and then updated it. upon restoring it brought back everything inside the bundled ios apps but the 3rd party apps and its data was gone!!!
    i disticntly remember 'syncing' it before restoring it but itunes 11.1 didn't 'transfer' the purchases on its own. i should had known. now my dad has lost considerible data like saved articles in various news apps, game data, etc...
    i dont know what to do. i dont know of this is reversible but if i could atleast know the best way to manage ios devices from multiple users with ONE ITUNES LIBRARY, that would be great!
    Neerav

    is this a bug or by design to not transfer purchases during sync?

  • How I download a MP4 series of videolectures (that the seller has stored in Amazon S3 and has sent to my iPad email address--which is different from the one I use from the MacBookPro) from my iPad to my MacBookPro-.

    How I download a MP4 series of videolectures (that the seller has stored in Amazon S3 and has sent to my iPad email address--which is different from the one I use from the MacBookPro) from my iPad to my MacBookPro (so that I can the save them in iTunes and then synchronize some of the videolectures to the iPad?)

    To set it up as POP you need to delete the account, reboot the phone by holding the HOME and SLEEP buttons at the same time until an Apple logo appears (about 10 seconds), then add it back following these instructions: Forcing creation of a POP or IMAP email account
    I understand that you have used the same account for many years, but the technology is also changing constantly. Years ago the standard was POP (Post Office Protocol), which was designed at a time when it was inconceivable that anyone would access their email from more than one device. When people started using multiple devices, for the most part they wanted to see changes on one device mirrored on another. A new standard, IMAP (Internet Mail Access Protocol) was developed. With iMAP the master copy of all messages resides on a server, and multiple devices are kept in sync with the server. So if you delete a message from one device it is removed from the server, and then removed from all other devices when they next sync. This is the same way Microsoft Exchange works. Other benefits of IMAP include the ability to have multiple mail folders that are kept in sync across devices. In your case you could use this to create a separate folder for each family member, so they could move messages to their own folder and not clutter up the shared Inbox. Most computer mail readers can even automatically sort incoming mail into folders based on the contents of the message.
    IMAP is considered a "higher level" standard than POP. When you create a mail account iOS devices query the server and ask what it supports; if it says it supports IMAP then the account is automatically configured for IMAP. So if you really want POP you must fool it, as described in the link above. In my experience Android devices default to the highest level protocol also, and I suspect newer Blackberries do (although it has been 15 years since I used a BB).

  • How to update my iphone 4 to ios 7 from 6.1.2

    How to update my iphone 4 to ios 7 from ios 6.1.2

    You can do this from the iPhones settings while connected to wifi or connecting the iPhone to a computer with iTunes. The article below will show you how:
    iOS: How to update your iPhone
    Note: It would be wise to back up your iPhone before updating and also checking out the new layout for iOS 7 to make sure the new look is something you like.

  • Cost Analysis result different from the cost estimate quantity structure re

    Hi
    Cost Analysis result different from the cost estimate quantity structure result in the same costing
    run why this happen like this. ( in CK40N costing run result -- Cost analysis -- double click on costing result it shows cost estimate quantity structure result values different from cost analysis value )
    Pls advice....
    Regards
    Kesharika

    It depends on your costing variant. For sample, if you take the price in the 1° price estimated on the material view and this data has changed, you can have a difference between the first and the second estimate.
    Perhaps also, it's just a definition of layout.
    And 3rd hypothesis : you are looking on component in the ck40n and the variant don't take in account your cost component and just the material price.
    Christophe

  • I cannot get my messages/text messages to work om my Hi.  I am sending this thru my iPad.  Respond and let me know you got it.  Fun fun fun.  .  I did go and try to another Apple ID different from my iPhone but it still will not work.  Can anyone help me?

    I cannot get my messages/text messages to work om my Hi.  I am sending this thru my iPad.  Respond and let me know you got it.  Fun fun fun.  .  I did go and try to another Apple ID different from my iPhone but it still will not work.  Can anyone help me?

    chicx wrote:
    This is the third time of writing this on your Apple Support Communities!
    Not with your current user id.
    Far too much uneccesary information in your post, which only confuses things, a vast amount!
    Let's start with iTunes.
    Have you updated iTunes to 11.1.5, because the previous version did appear to have an issue about seeing iPods?
    With iTunes 11.1.5 installed, look in Edit/Preferences/Devices, (or use the ALT key, followed by the E key and then the F key) and make sure that the box named Prevent iPods, iPhones and iPads from syncing automatically does not have a tick in the box.
    Once you have doen those two things, check to see if the iPod is seen by iTunes.
    chicx wrote:
    By the way, what does IOS mean? (I thought IO stood for operating system, but am flummoxed by the S on the end.
    Really?
    OS stands for Operating System. (In computer speak, IO means Input/Output.)
    iOS originally stood for iPhone Operating System, but it now refers to the iPod Touch and iPhone. The iPod Classic, which you have listed in your profile as your iPod, does not use iOS.
    I assume that you have been listening to the Podcast in your iTunes on the computer as you cannot transfer it to your iPod. It's what I'd do.

  • Question about garageband: I have 3 short original songs that i wanted to merge ala "Bohemian Rhapsody". Is that possible in garageband? their tempos are all different from each other. Advance thanks.

    Question about garageband: I have 3 short original songs that i wanted to merge ala "Bohemian Rhapsody". Is that possible in garageband? their tempos are all different from each other. Advance thanks.

    First of all, GarageBand iOS allows for only one tempo and there is no Merge Song feature.
    What you can do.
    Switch between the songs and copy-paste the individual Tracks. You can also Merge Tracks if you run into the 8 Track limitation.
    Hope that helps
    Edgar Rothermich
    http://DingDingMusic.com/Manuals
    'I may receive some form of compensation, financial or otherwise, from my recommendation or link.'

  • Switched from iPhone to Android and now iMessage being sent instead of Text

    A friend of mine recently switched from iPhone to Android and now my text are being sent as iMessage instead of text and he obviously isn't receiving it. How do I fix this bug. I'm using iPhone 4 running iOS 5

    I apologize about the odd style but I'm using voice rec software.  I just got the Galaxy S five and I have this problem too after weeks of searching online I finally figured out the problem it is with iMessage even if you have your old phones imessage switched off. you have to get your friends to text you normally and send. If the text bubble shows up blue, press and hold choose option send as SMS or text and the bubble will change to green green means SMS blue is the iMessage so its up to the iPhone user to take literally a half of an extra step to send a text to you and if they don't do that then they're just jerks

  • How to transfert my SMS from my old Android to my new iPhone ?

    Hi,
    All is in the title : How to transfert my SMS from my old Android to my new iPhone ?
    Is here an app to do this ??
    I'm in iOS 8.2 and my Android 4.4
    Thanks.

    You can't
    I'm sorry, but the iPhone can only build a new conversation, no import of another platform.
    Archive the old conversations on your computer and reference if needed. That's the best I've got.

  • Why is the library on my phone different from the one on my computer (I have iTunes Match)

    Why is the library on my phone different from the one on my computer? (I have iTunes Match) I just want the song off my computer to be the songs I have on my phone.

    Hey there Sparkly3gs,
    It sounds like your camera is not rotating as expected in the camera app. I want to recommend starting by quitting the running apps on the phone.
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    When you have done that restart the phone:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    If the issue persists, I would next backup your device to iTunes, and restore it:
    iOS: How to back up and restore your content
    http://support.apple.com/kb/HT1766
    I would suggest before restoring from your backup setup the device as new and make sure the camera functions as expected. Then restore from your backup and verify it still works.
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

Maybe you are looking for