Here are a few options that include the complete removal of the header:
- Fill the layout with
LayoutInflater . This layout will essentially be a LinearLayout or RelativeLayout , which contains all the components for the header . - or if that sounds like too much of a hastle, you can create a headline in your xml activity with the visibility set to gone and use
titleBarLayout.setVisibility(View.VISIBLE); when viewing a webpage loading
Pseudocode:
RelativeLayout activityLayout = (RelativeLayout) findViewById(R.id.my_layout); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); public void onWebViewFinishLoading() { LinearLayout myTitleBar = inflater.inflate(R.layout.my_title_bar, activityLayout, false);
Personally, I would go with the LayoutInflater option. But it is up to you. I believe that you can also add animation to your title bar displayed with any option, which can be a nice addition.
Or call this before setContentView :
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
This will return false if the custom title bar is not supported, so you can check this. This is called after setContentView :
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);
Assign the parent layout of the xml file ( LinearLayout or RelativeLayout , which contains all the views) id with android:id="@+id/custom_title_layout" .
Now,
LinearLayout titleBarLayout = (LinearLayout) findViewById(R.id.custom_title_layout);
And switch the title bar to be there or not to be used:
titleBarLayout.setVisibility(View.GONE);
b_yng source share