I found a issue that affects Relative Layout height while I was trying to add color to status bar.
adding Flag affected of calculation of the relative layouts rootView's height.
private void changeStatusBarColor(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(getResources().getColor(R.color.red_e31837));
}
}
I have a view tree observer that help me to track height of the rootView.
private ViewTreeObserver.OnGlobalLayoutListener keyboardLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = wrapper.getRootView().getHeight() - wrapper.getHeight();
}
int heightDiff
equals to 1920 if I use FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
but if I dont use changeStatusBarColor()
, int heightDiff
equals to 1776 (calculates without actionbar and statusbar I guess).
But Why adding this flag change calculations?
Thanks in advance!
In my case, problem was occured in SlidingMenu library. Here is a solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With