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:
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.setBackground(Helper.loadDrawableFromFile(this.getResources(), Helper.getBackgroundLoginImagePath()));
....
}
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.
So i changed my code to set the background image to the window in my activities onCreate:
@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()));
...
}
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).
What is happening there? Why is 'setBackgroundDrawable' stretching my image?
EDIT
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:
public Dialog onCreateDialog(Bundle savedInstanceState) {
...
dialog.getWindow().setBackgroundDrawable(Helper.loadDrawableFromFile(this.getResources(), Helper.getBackgroundLoginImagePath()));
...
}
so why isnt it working for an activity?