如何在webView中增加addView布局的高度?

时间:2014-09-01 12:06:39

标签: android webview

我是Android新手并制作一个应用程序,其中我需要在webView中增加addView子布局的高度,因为addview中出现的文本正在高度切割。请有人帮助我。感谢

这是webview代码:

question2 = new WebView(QuizActivityB.this);
// WebSettings webSettings = question2.getSettings();
// webSettings.setLoadsImagesAutomatically(true);

// webSettings.setSupportZoom(true);
// webSettings.setBuiltInZoomControls(true);
question2.getSettings().setRenderPriority(RenderPriority.HIGH);
question2.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);
question2.setWebChromeClient(new WebChromeClient());
question2.setBackgroundColor(Color.TRANSPARENT);
question2.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
question2.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);

layout.addView(question2);

1 个答案:

答案 0 :(得分:0)

调整或设置Height and Width dynamicallyLayoutParams设置为特定视图并将其添加到父版本

RelativeLayout layout = (RelativeLayout) findViewById(R.id.testlayout);
// create an object of your webview and set all the properties you want like background color etc.
MyWebView myWebView = new MyWebView(); 

layout.addView(myWebView, new RelativeLayout.LayoutParams(<my_width>,<my_height>);

另一种选择:

LayoutParams mParams = myWebView.getLayoutParams();
mParams.height = <my_height>;
mParams.width = <my_width>;
myWebView.setLayoutParams(mParams);