当我向下滚动它时,在网页视图中传递网址

时间:2017-01-09 12:36:58

标签: android webview popupwindow

enter image description here View at the bottom of my activity is hide popupwindow这是我的Java代码我正在为同一活动充气另一个布局并使用popupview显示:

 LayoutInflater layoutInflater = (LayoutInflater) StudyMaterial.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final View popupview = layoutInflater.inflate(R.layout.webview, null);
            PopupWindow popupWindow = new PopupWindow(popupview, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            popupWindow.setOutsideTouchable(true);
            WebView web = (WebView) popupview.findViewById(R.id.main);
            ImageView cancel = (ImageView) popupview.findViewById(R.id.cancel);
            web.getScrollY();
            cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    popupWindow.dismiss();
                }
            });
            web.getSettings().setJavaScriptEnabled(true);
            //web.getSettings().setPluginState(WebSettings.PluginState.ON);
            web.getSettings().setAllowFileAccess(true);
            //Toast.makeText(TeacherHome.this,"https://docs.google.com/gview?embedded=true&url="+url,Toast.LENGTH_LONG).show();
            web.loadUrl("http://www.javatpoint.com");
            popupWindow.showAsDropDown(popupview, 0, 0, Gravity.CENTER);

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.Toolbar
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:id="@+id/toolbar"
    app:elevation="3dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:title="View">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/cancel1"
        android:layout_gravity="end"
        android:layout_marginRight="10dp"
        android:id="@+id/cancel"/>
    </android.support.v7.widget.Toolbar>
<WebView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:id="@+id/main"/>
</LinearLayout>

当我向下滚动时,我的活动卡住并在其工具栏显示在底部后开始闪烁。

2 个答案:

答案 0 :(得分:0)

您可以像这样更改布局,然后重试:

Please note that if you are using server-side processing (serverSide) this option has no effect since the ordering and search actions are performed by a server-side script.

答案 1 :(得分:0)

您需要使用对话框而不是弹出窗口。这是更容易定制和实施非常容易..

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

将此添加到您的风格

 final Dialog d=new Dialog(this,R.style.fullscreendialog);
        d.setContentView(R.layout.webview);
        WebView web = (WebView) d.findViewById(R.id.main);
        ImageView cancel = (ImageView) d.findViewById(R.id.cancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                d.dismiss();
            }
        });
        web.getSettings().setJavaScriptEnabled(true);
        //web.getSettings().setPluginState(WebSettings.PluginState.ON);
        web.getSettings().setAllowFileAccess(true);
        //Toast.makeText(TeacherHome.this,"https://docs.google.com/gview?embedded=true&url="+url,Toast.LENGTH_LONG).show();
        web.loadUrl("http://www.javatpoint.com";
        d.show();
        d.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

添加主题对话框背后的原因继承为Theme.dialog的父级,这使得缩小只是从主题中移除父级作为魅力。