Results 1 to 4 of 4

Thread: get screen size on android application

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: get screen size on android application

    Hi
    i am new to sencha touch and I trying to get the screen size:

    width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
    height = (window.innerHeight > 0) ? window.innerHeight : screen.height;

    however, it returns 0!
    I think it's because the js of view is called before loading the browser, in an android application.
    is there any way to load the view after the browser?


  2. Hi!
    you may try following to get your screen size:-
    Code:
    Ext.getBody().getSize()
    For more info, check this:-
    http://docs.sencha.com/touch/2-0/#!/api/Ext-method-getBody
    http://docs.sencha.com/touch/2-0/#!/...method-getSize

  3. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    Vote Rating
    91
      0  

    Default

    Hi!
    you may try following to get your screen size:-
    Code:
    Ext.getBody().getSize()
    For more info, check this:-
    http://docs.sencha.com/touch/2-0/#!/api/Ext-method-getBody
    http://docs.sencha.com/touch/2-0/#!/...method-getSize
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  4. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Answers
    1
    Vote Rating
    0
      0  

    Default

    thanks for the reply,
    but also returns 0.

    I've tried
    Code:
      document.documentElement.clientWidth  window.innerWidth
      screen.width
      document.body.clientWidth
      document.getElementsByTagName('body')[0].clientHeight
      document.documentElement.offsetWidth
      Ext.global.outerWidth
      Ext.getBody().getSize()
    It seems the problem is that the browser is not loaded when running the script.

  5. #4
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Answers
    1
    Vote Rating
    0
      0  

    Default

    I solved the problem by writing the script in the event "painted" of a component, and setting the style via DOM.

Tags for this Thread

Posting Permissions

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