【问题标题】:How to HIDE/SHOW CUSTOM Title On button click In Android如何在 Android 中隐藏/显示自定义标题点击按钮
【发布时间】:2013-07-03 07:21:34
【问题描述】:

我正在开发一个安卓项目。我想在按钮单击时显示/隐藏自定义标题栏。此按钮用于媒体播放器(全屏尺寸/自定义屏幕尺寸)请帮助我。

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_main1);
        ctx=this;
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title1);
    //  FrameLayout frameLayout = (FrameLayout) findViewById(R.id.menu);
    //  FrameLayout frameLayout2 = (FrameLayout) findViewById(R.id.menu1);

为了隐藏自定义标题,我使用以下代码onClick()

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

【问题讨论】:

    标签: android titlebar


    【解决方案1】:

    这将隐藏操作栏:

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    这会让他回来:

    this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
    

    【讨论】:

    • 感谢您的回复。我试过这段代码,但发现错误 07-03 10:57:56.519: E/AndroidRuntime(1101): android.util.AndroidRuntimeException: requestFeature() must be called before added content
    猜你喜欢
    • 1970-01-01
    • 2019-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-21
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    相关资源
    最近更新 更多