androidstatusbaradjustpan

adjustPan not working with FLAG_LAYOUT_NO_LIMITS


My Requirement is a full transparent status bar with change color of the status bar in same activity dynamically.

For that, I added getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

and in style.xml

<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">false</item>

So It's working fine but I need to adjust screen when soft keypad opens. So I tried android:windowSoftInputMode="adjustPan|adjustResize" but screen not resized or scrolled. Anyone can help me on same.


Solution

  • Make transparent and change color dynamically like this dont set flag FLAG_LAYOUT_NO_LIMITS then check the screen when keypad is opened.

          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Window window = getWindow();
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                window.setStatusBarColor(getResources()
                        .getColor(R.color.themeToolbarColor));
            }