How to change WebView size

2

I have here a WebView that has height ( height ) of 0dp defined in the activity XML.

How can I change the height to 300dp programatically?

    
asked by anonymous 06.07.2015 / 12:36

1 answer

3

After a little research I discovered the solution to my problem

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

There is another way that it is for RelativeLayout round WebView and then put in java:

RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) someLayout.getLayoutParams(); 
params.height = 130; 
someLayout.setLayoutParams(params);
    
06.07.2015 / 13:23