How to change Webview size

Asked

Viewed 282 times

2

I got a WebView tall (height) of 0dp defined in the XML of the activity.

How can I change the height to 300dp programmatically?

1 answer

3


After researching a little I found the solution to my problem

mWebView=(WebView) findViewById(R.id.webView);
mWebView.setLayoutParams(new LinearLayout.LayoutParams(350,350));

There’s another way that’s by a RelativeLayout the return of WebView and then put it in the java :

RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) someLayout.getLayoutParams(); 
params.height = 130; 
someLayout.setLayoutParams(params);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.