Hello Member stackover。 我编程app andoid>我需要在弹出窗口中显示(查看)网页 我需要在beatuy设计中查看此页面 我使用了这个声明,但页面没有显示,popupwindow显示非常小。
主要活动:
button58.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentTransaction manger= getSupportFragmentManager().beginTransaction();
pop_web_view pop3 =new pop_web_view();
pop3.show(manger,null);
}
});
弹出窗口类:
public class pop_web_view extends DialogFragment implements View.OnClickListener{
View view;
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.web_view, container, false);
WebView webView = (WebView) view.findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://www.google.com");
return view;
}
答案 0 :(得分:1)
您应该为对话框设置宽度和高度
@Override
public void onStart() {
super.onStart();
Dialog d = getDialog();
if (d != null) {
int width = ViewGroup.LayoutParams.FILL_PARENT;
int height = ViewGroup.LayoutParams.FILL_PARENT;
d.getWindow().setLayout(width, height);
}
}
答案 1 :(得分:0)
webView = (WebView) view.findViewById(R.id.webview);
loadWebViewLoad(webView);
private void loadWebViewLoad(WebView webview) {
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.setWebViewClient(new WebViewClient());
webview.setWebChromeClient(new WebChromeClient());
webview.loadUrl(GlobalUrl);
}