简体   繁体   中英

Hide Toolbar Up Button in certain page of WebViewClient

I am trying to implement material design for my WebViewClient . The WebViewClient opens index.html saved in my asset. What I want to achieve is when the home page, index.html is opened, there shouldn't be a "up button". "Up button" should only be shown when I click on the link in index.html . I have tried

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

But apparently, this show "up button" for all of the pages. How to hide the "up button" for my homepage, index.html ?

Problem solved by adding this under onPageFinished in my WebViewClient

public void onPageFinished(WebView view, String url) {

        if (url.equals("file:///android_asset/index.html")) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        } else {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
        super.onPageFinished(view, url);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM