Skip to content

Dimensions.get('window').height is sometimes wrong on Android #4934

Closed
LedgerHQ/ledger-live-mobile
#617
@jaysoo

Description

@jaysoo

This only happens on a real device (I'm using OnePlus One). Could not reproduce on an emulator.

  1. Create an example app that displays the window height.
  2. Open the app for the first time.
  3. The height is reported as some value (e.g. 592 for me) -- See screenshot below
  4. Press home button.
  5. Go back to the example app.
  6. See that the window height is now different (e.g. 640 for me) -- See screenshot below

It seems that the first load, the height excludes the soft menu bar, but on subsequent reloads it includes it. (the soft menu bar for me is 48).

Here's the code I was running in my app:

'use strict';

const React = require('react-native');
const {
  AppRegistry,
  Dimensions,
  Text,
  View
  } = React;

const window = Dimensions.get('window');

const Example = React.createClass({
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <Text style={{ fontSize: 48}}>Height is {window.height}</Text>
      </View>
    );
  }
});

AppRegistry.registerComponent('Example', () => Example);

First load

screenshot dec 22 2015 4-58-01 pm

Reload

screenshot dec 22 2015 4-57-28 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions