title: getWindow().setBackgroundDrawable stretches background
body: <p>I created a background image which fits exactly into the device display without status bar and actionbar. That means the whole height of my device is 1280 pixels.
  Without statusbar and actionbar it is 1038 pixels. My background image is exactly 1038 pixels high. When i set the image as the background of my layout:</p>
  
  <pre><code>@Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
      super.onViewCreated(view, savedInstanceState);
  
      view.setBackground(Helper.loadDrawableFromFile(this.getResources(), Helper.getBackgroundLoginImagePath()));
  
      ....
  }
  </code></pre>
  
  <p>It fits perfectly into the screen as i want it to. the problem is that i have a scroll view and when i want to type something in my edittexts the keyboard pops up and my background image gets clinched.</p>
  
  <p>So i changed my code to set the background image to the window in my activities onCreate:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      this.setContentView(R.layout.activity_login);
      this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
      this.getWindow().setBackground(Helper.loadDrawableFromFile(this.getResources(), Helper.getBackgroundLoginImagePath()));
  
      ...
  }
  </code></pre>
  
  <p>But for some reason the background image now gets stretched so that the height is bigger than the original and i cant see the whole image. (its about 60 pixels to high).</p>
  
  <p>What is happening there? Why is 'setBackgroundDrawable' stretching my image?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>When i do the following in a dialog fragment, which in my opinion is exactly the same as doing it in an activity, works perfectly:</p>
  
  <pre><code>public Dialog onCreateDialog(Bundle savedInstanceState) {
      ...
  
      dialog.getWindow().setBackgroundDrawable(Helper.loadDrawableFromFile(this.getResources(), Helper.getBackgroundLoginImagePath()));
  
      ...
  }
  </code></pre>
  
  <p>so why isnt it working for an activity?</p>