Search code examples
androidprogress-bartitlebarandroid-titlebar

Android hiding the title bar after progress bar finishes loading


I'm trying to hide the title bar after the progress bar finishes loading on top. Could anyone show me how it is done? Thanks

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        //this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); **//Putting this make the whole title bar hidden**
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        this.getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

        setContentView(R.layout.main);

Bunch of codes...

webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress)   
            {
             //Make the bar disappear after URL is loaded, and changes string to Loading...
            MyActivity.setTitle("Loading...");
             MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded

             // Return the app name after finish loading
                if(progress == 100)

             this.requestWindowFeature(Window.FEATURE_NO_TITLE);**//Not Working (shows Error The method requestWindowFeature(int) is undefined for the type new WebChromeClient(){} )**  
              //MyActivity.setTitle(R.string.app_name);

              }



            });
        webView.setWebViewClient(new InsideWebViewClient());


    }

Solution

  • You need to write following syntax into your AndroidManifest.xml file

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    

    and if you want to do it through coding in Activity then you can use following code, in OnCreate() method of Activity.

    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);