从全屏模式的Andr​​oid退出全屏、模式、oid、Andr

2023-09-04 04:18:15 作者:久了久了就旧了

我在Android的工作。我需要证明我在全屏模式下的活动,我这样做是使用以下code。

I am working in Android. I need to show my activity in Full screen mode, and i did this using following code.

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

现在它看起来像这样: -

Now its looking like this:-

现在我想从这个充满模式中退出,所以我的活动应该像以前一样显示。像这样的: -

Now I want to exit from this full mode so my activity should show as before. like this:-

我有一个用于全模式或正常模式间切换按钮,我会一次又一次地切换模式。请建议我怎么能做到这一点。指如何让普通屏的全屏显示。

I have a button which is used to switch between full mode or normal mode, i will switch mode again and again. Please suggest me how can i do this. Means how can get normal screen from full screen.

感谢你在前进。

推荐答案

按照以下code,我可以隐藏 TitleBar中按您的需求,

As per below code, i can hide the TitleBar by your needs,

Button full;
static int vari = 0;

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    full = (Button)findViewById(R.id.fullview);
    full.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if(vari == 0)
            {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                vari = 1;
            }else 
            {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);                 
                vari = 0;
            }

        }
    });
}

试试这个code。它可以帮助你很多东西。

Try this code. It helps you lot.