0

我有一个应用程序可以在特定条件下在全屏和普通屏幕之间切换。我已通过通知成功完成此操作,但在将其从全屏模式设置回正常屏幕模式后,标题栏仍保持隐藏状态。那么隐藏后如何显示标题栏?

编辑:

我遇到了他们制作自定义标题栏并在其可见性之间切换的答案,但这不是我想要的。

代码:

if(ScreenReceiver.wasScreenOn) {
    Toast toast=Toast.makeText(this, "screen was on", Toast.LENGTH_LONG);
    toast.show();
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setContentView(R.layout.resume);
} else { 
    Toast toast=Toast.makeText(this, "screen was off", Toast.LENGTH_LONG);
    toast.show();
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setContentView(R.layout.main);
}
4

1 回答 1

-1

试试这个

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


/// custom tittle bar declaration 
final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

/// custom tittle bar creation ///....
    if (customTitleSupported) {
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tittle_bar);
    }
    final TextView myTitleText = (TextView) findViewById(R.id.title_bar);
    if (myTitleText != null) {
        myTitleText.setText("Categories");
    }
于 2012-07-06T04:32:09.407 回答