3

I would like to explain what i am doing now. I developed an aar(sdk) and is running fine. However, i would like my sdk to occupy full screen when being called, even the caller has a toolbar. i tried the sample from this link

[How to set activity to fullscreen mode in Android?

However, if i put the code in android Manifest of the sdk, my app will crashed. If i do it when sdk activity OnCreate as below code. The toolbar still there.

requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_sdk_main);

May I know what do i need to do to hide the toolbar. Thanks.

Community
  • 1
  • 1
kggoh
  • 742
  • 1
  • 10
  • 24

3 Answers3

0

If you want full screen mode for particular activity then use this

protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

and for all activities Create a BaseActivity and write its onCreate method as shown above and extend this base activity for all other activities.

Rajesh Gosemath
  • 1,812
  • 1
  • 17
  • 31
  • sorry. that's i already tried before posting this question. i tried both add that code before and after setContentView. Both not working. – kggoh Dec 02 '16 at 04:32
0
getSupportActionBar().hide(); 

works.

Additional explaination, my class is an extension of AppCompatActivity, below is the code.

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Logger.d(SdkMainActivity.class, "onCreate");
            getSupportActionBar().hide();    //---> this works

    //requestWindowFeature(Window.FEATURE_NO_TITLE);    //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);   // ---> this the toolbar still appear

            setContentView(R.layout.activity_sdk_main);

}
kggoh
  • 742
  • 1
  • 10
  • 24
0
public void setFullScreenView() {//Hiding status/navigation bar
    if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) {
        View v = this.getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else if (Build.VERSION.SDK_INT >= 19) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    }
    setContentView(R.layout.activity_splash_screen);
}
Rajesh
  • 2,618
  • 19
  • 25