Results 1 to 4 of 4

Thread: Positioning an image with absolute x-y coordinates

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    15
    Answers
    2
    Vote Rating
    0
      0  

    Default Answered: Positioning an image with absolute x-y coordinates

    Hello everyone,

    I'm new to Sencha Touch, and would like to redesign my existing Android App to work with Sencha Touch and Phongeap. I'd like to place a picture with absolute x-y coordinates oin the screen and make it draggable. Is there something like an absolute layout for Sencha Touch?

    Cheers,
    Glasgow

  2. You can use setPosition passing in the top and left value. It's not 100% like x/y but close

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    You can use setPosition passing in the top and left value. It's not 100% like x/y but close
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    1
    Vote Rating
    0
      0  

    Default Set X-Y position of any component

    Ext.getCmp('image').el.setX(10);
    Ext.getCmp('image').el.setY(10);

  5. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    15
    Answers
    2
    Vote Rating
    0
      0  

    Default

    Thanks for the fast replies, but unfortunately I can't make it work and can't figure out why. It only places a div tag at position 100 100 instead of the image. My goal is to place multiple pics within my panel at absolute positions. I found this code on another thread, but don't know how to use it correctly.

    This is my complete source:

    Code:
    ...
    Cheers,
    Glasgow

    EDIT: Sorry everyone, I see that my example code was again ExtJs. I found in this thread how simple it is to place pics. I thought the id of the item is the same as the id tag within the <img>-html code. Here is the working code:
    Code:
    new Ext.Application({    launch: function() {
            new Ext.Panel({
                fullscreen: true,
                layout: 'fit',
                cls: 'hintergrund',
                items: [{xtype: 'panel', html: '<img src="http://dgrosche.charlottenthal.de/images/passbild.jpg">', id: 'imgPreview'}]
            });
            
            Ext.getCmp('imgPreview').setPosition(100, 100);
        }
    });
    Last edited by GlasgowKid; 17 Jan 2012 at 12:23 AM. Reason: Found solution on my own

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •