开发者

Enabling and disabling title bar in android

开发者 https://www.devze.com 2023-03-28 22:28 出处:网络
I want to enable and disable the title bar ba开发者_StackOverflow社区sed on the entry point for the activity. How can i do it(may it be in xml or in code)?

I want to enable and disable the title bar ba开发者_StackOverflow社区sed on the entry point for the activity. How can i do it(may it be in xml or in code)? Thanks in advance.


you can hide the title bar like this way

//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

or modify in xml file like this way

<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">

or using style with xml file like this way

<style name="generalnotitle" parent="general">
    <item name="android:windowNoTitle">true</item>
</style>


Try this.. its a hack..

titleView = getWindow().findViewById(android.R.id.title);
    if (titleView != null) {
        ViewParent parent = titleView.getParent();
        if (parent != null && (parent instanceof View)) {
         View parentView = (View)parent;
         parentView.setVisibility(View.GONE);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消