1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Vote Rating
    0
    Answers
    1
    carloshike is on a distinguished road

      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,334
    Vote Rating
    87
    Answers
    124
    sword-it is just really nice sword-it is just really nice sword-it is just really nice sword-it is just really nice

      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
    Vote Rating
    0
    Answers
    1
    carloshike is on a distinguished road

      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
    Vote Rating
    0
    Answers
    1
    carloshike is on a distinguished road

      0  

    Default

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

Thread Participants: 1

Tags for this Thread