在Android Webview中隐藏下载按钮

在Android Webview中隐藏下载按钮,android,html,css,Android,Html,Css,我想在网站上显示“立即下载应用程序”按钮,但我想在webview android应用程序中隐藏该按钮。它应该只显示在网站上,而不是在webview应用程序中 可能吗?如果是,怎么做 css文件 .desk { width: 250px; height: 70px; color: white; font-family: sans-serif; text-decoration: none; font-size: 1.5em; position:

我想在网站上显示“立即下载应用程序”按钮,但我想在webview android应用程序中隐藏该按钮。它应该只显示在网站上,而不是在webview应用程序中

可能吗?如果是,怎么做

css文件

.desk {
    width: 250px;
    height: 70px;
    color: white;
    font-family: sans-serif;
    text-decoration: none;
    font-size: 1.5em;
    position: fixed;
    transform: translate(35%, -25%);
    top: 50%; 
    right: 50%;
}
@media screen and (max-width : 906px) {
     .desk {
          visibility:hidden;
     }
}
html

      <div class="desk">
 <a href="./download.php?file=app.apk" class="buttonDownload"><img src="img/playstore-app.jpg"  height="35" width="120">
</a>  

 </div>

Main_activity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    webView = (WebView) findViewById(R.id.webView);
    WebSettings mWebSettings = webView.getSettings();
    webView.setWebViewClient(new WebViewClient());
    mWebSettings.setJavaScriptEnabled(true);
    mWebSettings.setSupportZoom(false);
    mWebSettings.setAllowFileAccess(true);
    mWebSettings.setAllowFileAccess(true);
    mWebSettings.setAllowContentAccess(true);
    webView.loadUrl("https://worldfamoushub.com");
    webView.loadUrl("javascript:document.getElementsByClassName('desk')[0].style.display='none';");
    webView.setWebChromeClient(new WebChromeClient() {
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
            if (mUMA != null) {
                mUMA.onReceiveValue(null);
            }
            mUMA = filePathCallback;
            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (takePictureIntent.resolveActivity(MainActivity.this.getPackageManager()) != null) {
                File photoFile = null;
                try {
                    photoFile = createImageFile();
                    takePictureIntent.putExtra("PhotoPath", mCM);
                } catch (IOException ex) {
                    Log.e("Webview", "Image file creation failed", ex);
                }
                if (photoFile != null) {
                    mCM = "file:" + photoFile.getAbsolutePath();
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                } else {
                    takePictureIntent = null;
                }
            }

            Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
            contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
            contentSelectionIntent.setType("*/*");
            Intent[] intentArray;
            if (takePictureIntent != null) {
                intentArray = new Intent[]{takePictureIntent};
            } else {
                intentArray = new Intent[0];
            }

            Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
            chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
            chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
            startActivityForResult(chooserIntent, FCR);
            return true;
        }
    });

}
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView=(webView)findviewbyd(R.id.webView);
WebSettings mWebSettings=webView.getSettings();
setWebViewClient(新的WebViewClient());
mWebSettings.setJavaScriptEnabled(true);
mWebSettings.setSupportZoom(假);
mWebSettings.setAllowFileAccess(true);
mWebSettings.setAllowFileAccess(true);
mWebSettings.setAllowContentAccess(true);
webView.loadUrl(“https://worldfamoushub.com");
webView.loadUrl(“javascript:document.getElementsByClassName('desk')[0].style.display='none';”;
setWebView.WebChromeClient(新WebChromeClient(){
公共布尔onShowFileChooser(WebView WebView、ValueCallback filePathCallback、WebChromeClient.FileChooseParams FileChooseParams){
如果(mUMA!=null){
mUMA.onReceiveValue(空);
}
mUMA=filePathCallback;
Intent takePictureIntent=新的意图(MediaStore.ACTION\u IMAGE\u CAPTURE);
if(takePictureContent.resolveActivity(MainActivity.this.getPackageManager())!=null){
文件photoFile=null;
试一试{
photoFile=createImageFile();
takePictureContent.putExtra(“光路”,mCM);
}捕获(IOEX异常){
Log.e(“Webview”,“图像文件创建失败”,ex);
}
if(photoFile!=null){
mCM=“文件:”+photoFile.getAbsolutePath();
takePictureContent.putExtra(MediaStore.EXTRA_输出,Uri.fromFile(photoFile));
}否则{
takePictureContent=null;
}
}
意图内容SelectionContent=新意图(Intent.ACTION\u GET\u CONTENT);
ContentSelectionContent.addCategory(Intent.CATEGORY\u可打开);
contentSelectionContent.setType(“*/*”);
意图[]意图射线;
if(takePictureContent!=null){
intentArray=newintent[]{takePictureIntent};
}否则{
intentArray=新意图[0];
}
意图选择器content=新意图(Intent.ACTION\u选择器);
选择content.putExtra(Intent.EXTRA\u Intent,content selection内容);
选择content.putExtra(Intent.EXTRA_标题,“图像选择器”);
选择content.putExtra(Intent.EXTRA\u INITIAL\u INTENTS,intentArray);
startActivityForResult(选择内容,FCR);
返回true;
}
});
}

问题是它会出现在所有手机上。我希望这个按钮从android webview中消失。是否可以在移动web浏览器中显示,但不能在webview应用程序中显示?

这就是您要找的吗?相关:试试这个:你能指出代码main_activity.java中的错误吗?webView.loadUrl(“javascript:document.getElementsByClassName('desk')[0].style.display='none';”)。。。这似乎做得不对。