android - requestWindowFeature(Window.FEATURE_NO_TITLE) exception

后端 未结 5 511
后悔当初
后悔当初 2020-12-21 18:14

I am setting a specific activity full screen when the use hits a START button.

In this case the showStopButton() is called .

It\'s running fine

相关标签:
5条回答
  • 2020-12-21 18:31

    it's so simple ... I just need to hide the ActionBar... then show it when back to standard screen...

       private void showStopButton(){
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            ActionBar actionBar = getActionBar();
            actionBar.hide();
            getWindow().findViewById(android.R.id.content).requestLayout();
    
    0 讨论(0)
  • 2020-12-21 18:39

    So:

    @Override
    protected void onCreate(
        final Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    
        // Make this activity, full screen
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
        // Hide the Title bar of this activity screen
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    
        setContentView(R.layout.main);
    
        // MORE INIT STUFF HERE...
        //img = (ImageView) findViewById(R.id.imgRandom);
        //btnRandom = (Button) findViewById(R.id.btnRandom);
    }
    
    0 讨论(0)
  • 2020-12-21 18:47

    Add this.

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    before

     super.onCreate(savedInstanceState);
     setContentView(R.layout.your activity);
    
    0 讨论(0)
  • 2020-12-21 18:48

    Use -public class MainActivity extends Activity- instead of -public class MainActivity extends ActionBarActivity-

    0 讨论(0)
  • 2020-12-21 18:54

    Try this one......

    public class MainActivity extends Activity {
    
        Context context;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            context = this;
    
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
            setContentView(R.layout.activity_main);
        }
    }
    
    0 讨论(0)
提交回复
热议问题