我正在尝试为我的 WebViewClient
实现 Material 设计。 WebViewClient
打开保存在我的 Assets 中的 index.html
。我想要实现的是当主页 index.html
打开时,不应该有“向上按钮”。 “向上按钮”应该只在我点击 index.html
中的链接时显示。我试过了
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
但显然,这会为所有页面显示“向上按钮”。如何隐藏主页 index.html
的“向上按钮”?
最佳答案
通过在我的 WebViewClient
的 onPageFinished
下添加这个解决了问题
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);
}
关于android - 在WebViewClient的某个页面隐藏工具栏向上按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34985579/