本文整理汇总了Java中android.webkit.WebView.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setLayoutParams方法的具体用法?Java WebView.setLayoutParams怎么用?Java WebView.setLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebView
的用法示例。
在下文中一共展示了WebView.setLayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
LinearLayout webViewContainer = new LinearLayout(getContext());
webView = new WebView(getContext());
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new DialogWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
webView.setVisibility(View.INVISIBLE);
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
webViewContainer.setPadding(margin, margin, margin, margin);
webViewContainer.addView(webView);
webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
contentFrameLayout.addView(webViewContainer);
}
示例2: getView
import android.webkit.WebView; //导入方法依赖的package包/类
@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;
}
示例3: onException
import android.webkit.WebView; //导入方法依赖的package包/类
@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);
container.removeAllViews();
container.addView(webView);
webView.loadUrl(((WXEmbed)comp).src);
}else{
super.onException(comp,errCode,msg);
}
}
示例4: onException
import android.webkit.WebView; //导入方法依赖的package包/类
@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);
}
}
示例5: initView
import android.webkit.WebView; //导入方法依赖的package包/类
private void initView() {
// //动态添加webview,防止webview内存泄露
RelativeLayout layout_content= (RelativeLayout) findViewById(R.id.layout_content);
webView=new WebView(this);
webView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
layout_content.addView(webView);
// webView = (WebView) findViewById(R.id.webView);
layout_no_data = (RelativeLayout) findViewById(R.id.layout_no_data);
top_bar = (LinearLayout) findViewById(R.id.top_bar);
left_btn = (ImageView) findViewById(R.id.left_btn);
middleTitle = (TextView) findViewById(R.id.middleTitle);
rightBtn = (ImageView) findViewById(R.id.right_home_btn);
rightShareButton = (ImageView) findViewById(R.id.right_share_btn);
//设置webview相关设置
initWebView(webView);
//设置webview相关事件
initWebEvent(webView);
}
示例6: initView
import android.webkit.WebView; //导入方法依赖的package包/类
private void initView() {
try {
udeskWebChromeClient = new UdeskWebChromeClient(this, new UdeskWebChromeClient.ICloseWindow() {
@Override
public void closeActivty() {
finish();
}
});
linearLayout = (LinearLayout) findViewById(R.id.udesk_webview_root);
mTitlebar = (UdeskTitleBar) findViewById(R.id.udesktitlebar);
mwebView = new WebView(this);
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.
LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
mwebView.setLayoutParams(param);
linearLayout.addView(mwebView);
settingWebView();
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private void setUpWebView() {
mSpinner = new ProgressDialog(this);
mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSpinner.setMessage("Loading...");
mWebView = new WebView(this);
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new InstagramWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mAuthUrl);
mWebView.setLayoutParams(FILL);
WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
clearCache();
addContentView(mWebView,FILL);
}
示例8: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
/**
* 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);
}
示例9: onCreateView
import android.webkit.WebView; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_player, container, false);
WebView playerWebView = ((MainActivity)getActivity()).playerWebView;
LinearLayout playerContainer = view.findViewById(R.id.player_container);
if(playerWebView.getParent() != null)
((ViewGroup)playerWebView.getParent()).removeView(playerWebView);
playerWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
playerContainer.addView(playerWebView);
LinearLayout chatContainer = view.findViewById(R.id.chat_container);
if(PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("enable_chat", true) && !getArguments().getBoolean("video")) {
WebView chatWebView = ((MainActivity)getActivity()).chatWebView;
if(chatWebView.getParent() != null)
((ViewGroup)chatWebView.getParent()).removeView(chatWebView);
chatWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
chatContainer.addView(chatWebView);
} else {
View infoView = inflater.inflate(R.layout.fragment_stream_info, container, false);
infoView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
chatContainer.addView(infoView);
TextView titleText = chatContainer.findViewById(R.id.infoStreamTitle);
titleText.setText(getArguments().getString("title"));
}
return view;
}
示例10: createWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private WebView createWebView(Context context) {
WebView view = new WebView(context);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
view.setLayoutParams(layoutParams);
view.setWebViewClient(new WebViewClient() {
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView wView, String url) {
if (url.contains(webOptions.getCloseUrl())) {
cancel();
String[] urlComponents = url.split("\\?");
if (urlComponents.length > 1) {
String queryString = urlComponents[1];
String[] parameters = queryString.split("&");
for (String parameter : parameters) {
String[] parameterComponents = parameter.split("=");
if (parameterComponents.length > 1 && parameterComponents[0].equals("result")) {
Leanplum.track(parameterComponents[1]);
}
}
}
return true;
}
return false;
}
});
view.loadUrl(webOptions.getUrl());
return view;
}
示例11: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override
/**
* When the dialog is created, we add the webview and load the authorize url.
*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mProgress = new ProgressDialog(getContext());
mProgress.requestWindowFeature(Window.FEATURE_NO_TITLE);
mProgress.setMessage("Loading...");
mLayout = new LinearLayout(getContext());
mLayout.setOrientation(LinearLayout.VERTICAL);
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
//mWebView.getSettings().setSupportZoom(false);
mWebView.setLayoutParams(MATCH);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new OAuthWebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl(mReq.getLocationUri());
mLayout.addView(mWebView);
Display display = getWindow().getWindowManager().getDefaultDisplay();
addContentView(mLayout, new FrameLayout.LayoutParams(display.getWidth() - 20, display.getHeight() - 20));
CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
示例12: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new TwitterWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
mContent.addView(mWebView);
}
示例13: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new FoursquareDialog.FoursquareWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
示例14: initViews
import android.webkit.WebView; //导入方法依赖的package包/类
private void initViews() {
versionCode = BuildConfig.VERSION_CODE;
mFrameLayout = (FrameLayout) findViewById(R.id.frame_layout);
mWebView = new WebView(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mWebView.setLayoutParams(layoutParams);
mFrameLayout.addView(mWebView);
tv_url_title = (TextView) findViewById(R.id.tv_url_title);
rl_back = (RelativeLayout) findViewById(R.id.rl_back);
rl_option = (RelativeLayout) findViewById(R.id.rl_option);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
}
示例15: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
LinearLayout webViewContainer = new LinearLayout(getContext());
webView = new WebView(getContext().getApplicationContext()) {
/* Prevent NPE on Motorola 2.2 devices
* See https://groups.google.com/forum/?fromgroups=#!topic/android-developers/ktbwY2gtLKQ
*/
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
try {
super.onWindowFocusChanged(hasWindowFocus);
} catch (NullPointerException e) {
}
}
};
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new DialogWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
webView.setVisibility(View.INVISIBLE);
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (!v.hasFocus())
{
v.requestFocus();
}
return false;
}
});
webViewContainer.setPadding(margin, margin, margin, margin);
webViewContainer.addView(webView);
webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
contentFrameLayout.addView(webViewContainer);
}