5

I am working on my full-screen project recently, and it's implemented by Immersive mode. It works fine and correctly except one part:

As keyboard popping up, hiding status bar will also shows up.

How can I get rid of it? I want status bar keep hiding when I click edittext in my layout.

here's my code:

    int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE
                    |View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    |View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    |View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    |View.SYSTEM_UI_FLAG_FULLSCREEN
                    |View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mDecorView = activity.getWindow().getDecorView();
        mDecorView.setSystemUiVisibility(flag);     
        mDecorView.setOnSystemUiVisibilityChangeListener(
            new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0) {
                    mDecorView.setSystemUiVisibility(flag);
                }
            }
        });
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0) {
            mDecorView.setSystemUiVisibility(flag);
        }
    }

It must have some walk-around solution. I've seen that some app hide status bar well even when keyboard popup.

Any ideas how to solve this?

Timothy
  • 101
  • 1
  • 7
  • I think when the keyboard is up, the return button etc goes up to so you will be able to close the keyboard and also the status bar... – DavidBalas Aug 31 '15 at 15:32
  • I think that it is a functionality of the immersive mode. But look this post, maybe you could get some useful information http://stackoverflow.com/questions/21164836/immersive-mode-navigation-becomes-sticky-after-volume-press-or-minimise-restore/21278040#21278040 – Víctor Martín Aug 31 '15 at 15:37

1 Answers1

-1

you must use <ScrollView> as main layout. example:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   ....
</ScrollView>

or use this code in AndroidManiFest.xml:

<activity
     android:windowSoftInputMode="adjustNothing">
</activity>
سعید .م
  • 137
  • 1
  • 8