本文整理了Java中android.webkit.WebView.setLayoutParams()
方法的一些代码示例,展示了WebView.setLayoutParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.setLayoutParams()
方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:setLayoutParams
暂无
代码示例来源:origin: stackoverflow.com
public class ServiceWithWebView extends Service {
@Override
public void onCreate() {
super.onCreate();
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
params.x = 0;
params.y = 0;
params.width = 0;
params.height = 0;
LinearLayout view = new LinearLayout(this);
view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
WebView wv = new WebView(this);
wv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
view.addView(wv);
wv.loadUrl("http://google.com");
windowManager.addView(view, params);
}
}
代码示例来源:origin: facebook/facebook-android-sdk
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
webView.setVisibility(View.INVISIBLE);
代码示例来源:origin: stackoverflow.com
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldReturnPreviouslySetLayoutParams() {
assertThat(webView.getLayoutParams()).isNull();
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
webView.setLayoutParams(params);
assertThat(webView.getLayoutParams()).isSameAs(params);
}
代码示例来源:origin: stackoverflow.com
mWebviewPop.getSettings().setJavaScriptEnabled(true);
mWebviewPop.getSettings().setSavePassword(false);
mWebviewPop.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
mContainer.addView(mWebviewPop);
代码示例来源:origin: stackoverflow.com
final class MyChromeClient extends WebChromeClient {
// Add new webview in same window
@Override
public boolean onCreateWindow(WebView view, boolean dialog,
boolean userGesture, Message resultMsg) {
WebView childView = new WebView(getContext());
childView.getSettings().setJavaScriptEnabled(true);
childView.setWebChromeClient(this);
childView.setWebViewClient(new FacebookWebViewClient());
childView.setLayoutParams(FILL);
mContent.addView(childView);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(childView);
resultMsg.sendToTarget();
return true;
}
// remove new added webview whenever onCloseWindow gets called for new webview.
@Override
public void onCloseWindow(WebView window) {
mContent.removeViewAt(mContent.getChildCount() - 1);
}
}
代码示例来源:origin: weexteam/weex-hackernews
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onException(NestedContainer comp, String errCode, String msg) {
//downgrade embed
if( errCode != null && comp instanceof WXEmbed && errCode.startsWith("1|")) {
ViewGroup container = comp.getViewContainer();
WebView webView = new WebView(container.getContext());
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
webView.setLayoutParams(params);
webView.getSettings().setJavaScriptEnabled(true);
//WebView Remote Code Execution Vulnerability
webView.removeJavascriptInterface("searchBoxJavaBridge_");
webView.removeJavascriptInterface("accessibility");
webView.removeJavascriptInterface("accessibilityTraversal");
webView.getSettings().setSavePassword(false);
container.removeAllViews();
container.addView(webView);
webView.loadUrl(((WXEmbed) comp).src);
}else{
super.onException(comp,errCode,msg);
}
}
}
代码示例来源:origin: JasonQS/Anti-recall
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
代码示例来源:origin: weexteam/weex-hackernews
@Override
public View getView() {
FrameLayout root = new FrameLayout(mContext);
root.setBackgroundColor(Color.WHITE);
mWebView = new WebView(mContext);//mContext.getApplicationContext();
FrameLayout.LayoutParams wvLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
wvLayoutParams.gravity = Gravity.CENTER;
mWebView.setLayoutParams(wvLayoutParams);
root.addView(mWebView);
initWebView(mWebView);
mProgressBar = new ProgressBar(mContext);
showProgressBar(false);
FrameLayout.LayoutParams pLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
mProgressBar.setLayoutParams(pLayoutParams);
pLayoutParams.gravity = Gravity.CENTER;
root.addView(mProgressBar);
return root;
}
代码示例来源:origin: stackoverflow.com
apple.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(TestKeyboard.this);
WebView view = new WebView(Fruits.this);
view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
builder.setView(view);
builder.create().show();
view.loadUrl("file:///android_asset/apple.gif");
}
});
代码示例来源:origin: stackoverflow.com
LinearLayout root = new LinearLayout(this);
root.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
WebView wv = new WebView(this);
wv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("http://www.google.com");
root.addView(wv);
setContentView(root);
代码示例来源:origin: stackoverflow.com
WebView mWebView = new WebView(context);
RelativeLayout.LayoutParams paramsWV = new RelativeLayout.LayoutParams(mRelativeLayout.getWidth(), mRelativeLayout.getHeight);
mParamsWM.addRule(RelativeLayout.LayoutParams.FILL_PARENT);//so the web view fill the layout
mWebView.setLayoutParams(mParamsWM);
mWebView.loadData(htmlContent, "text/html", "UTF-8");
mRelativeLayout.addView(mWebView);
代码示例来源:origin: com.novoda/notils
private void createWebView() {
webView = new WebView(this);
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
webView.setLayoutParams(p);
}
代码示例来源:origin: stackoverflow.com
WebView webview = new WebView(activity);
webview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
String html = "<!DOCTYPE html><html><body bgcolor=\"#7f7f7f\"><img src=\"data:image/png;base64,"
+ imageArray.get(position) + "\" hspace=10 vspace=10><br>";
html += "</body></html>";
webview.getSettings().setBuiltInZoomControls(true);
webview.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
代码示例来源:origin: stackoverflow.com
WebView webview = (WebView)findViewById(R.id.webview);
MarginLayoutParams marginsParams = new MarginLayoutParams(webview.getLayoutParams());
marginsParams.setMargins(50, 50,1024-50, 600-50);
RelativeLayout.LayoutParams lp = new LayoutParams(marginsParams);
webview.setLayoutParams(lp);
代码示例来源:origin: stackoverflow.com
public void showZoomableImage(String fileUrl) {
Dialog d = new Dialog(mContext, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
d.setCancelable(true);
WebView wv = new WebView(mContext);
wv.setLayoutParams(new LayoutParams(android.widget.TableRow.LayoutParams.MATCH_PARENT, android.widget.TableRow.LayoutParams.MATCH_PARENT));
wv.loadUrl(fileUrl);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setSupportZoom(true)
d.setContentView(iv);
d.show();
}
代码示例来源:origin: stackoverflow.com
WebView webView = new WebView(this);
RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 416);
WebSettings webSettings = webView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webView.setLayoutParams(p);
webView.loadUrl("http://www.google.com/");
代码示例来源:origin: multidots/android-social-signin-helper
/**
* Creating webview for instagram dialog login
*/
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new OAuthWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
代码示例来源:origin: hefuyicoder/ZhihuDaily
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mStoryHeaderView = StoryHeaderView.newInstance(container);
mWebViewSoftReference = new SoftReference<>(new WebView(getActivity()));
if (isWebViewOK()) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams
(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mWebViewSoftReference.get().setLayoutParams(layoutParams);
}
return inflater.inflate(R.layout.fragment_story, container, false);
}
代码示例来源:origin: stackoverflow.com
WebView w =new WebView(this);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
w.setLayoutParams(lp);
w.getLayoutParams().width = 200;
w.getLayoutParams().height = 200;
( (ViewGroup) insertPoint ).addView(w) ;
内容来源于网络,如有侵权,请联系作者删除!