How to keep theme layout the same when admin gray bar is present?

The top bar of your theme is also positioned absolutely, so it doesn’t know to come down. You can use is_admin_bar_showing() to check to see if it’s showing, and then I’d probably just inject some styles using wp_head to move it down, since it’s very little CSS.

All told, you’d get something in your theme’s functions.php like:

add_action( 'wp_head', 'prefix_move_theme_down' );
function prefix_move_theme_down() {
  if ( is_admin_bar_showing() ) {
    ?>
    <style type="text/css">
    #header { top: 28px; }
    #content { margin-top: 68px; }
    </style>
    <?php
  }
}