I want to dynamically create a `web view` and on click change the size of the webview to `fill_parent` and after on click again it should revert back to the previous dimensions i has custom set. I have been able to create a web view dynamically so far and tried passing new parameters on click but what happens is that webview covers the whole screen and does not revert to the previous size after the second click.

Any help is appreciated.

My current code looks similar to this.

```
public class MainActivity extends Activity {
    RelativeLayout layout;
    Boolean flag=true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        layout=(RelativeLayout)findViewById(R.id.test);

        TextView textDynamic = new TextView(this);
        textDynamic.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        textDynamic.setText("Hello Android");
        layout.addView(textDynamic); 

        final WebView web = new WebView(this);
        web.getSettings().setJavaScriptEnabled(true);

            final RelativeLayout.LayoutParams webViewParams = new RelativeLayout.LayoutParams(
                    300, 100);
            webViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

            final RelativeLayout.LayoutParams webViewNewParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);

        web.loadData("<script type=\"text/javascript\" src=\"http://myurl.com/test.php\"></script>", null, null);
//RelativeLayout.LayoutParams webViewParams = new RelativeLayout.LayoutParams(
        //      300, 100);
    //  final RelativeLayout.LayoutParams webViewNewParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);

        layout.addView(web, webViewParams);
        web.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View arg0, MotionEvent arg1) {
            if(arg1.getAction()==MotionEvent.ACTION_UP)
            {
            Log.e("test", "msg");
            layout.removeView(web);
            //web.getSettings().setDefaultZoom(ZoomDensity.FAR);

            if (flag=true)
            {
                flag=false;
                web.getSettings().setLoadWithOverviewMode(true);
                web.getSettings().setUseWideViewPort(true);
                layout.addView(web, webViewNewParams);

            }
            else
            {
                flag=true;
                web.getSettings().setLoadWithOverviewMode(false);
                web.getSettings().setUseWideViewPort(false);
                //webViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                layout.addView(web, webViewParams);

            }
        //  web.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
        //web.setLayoutParams(webViewNewParams);
            //web.setLayoutParams(new RelativeLayout.LayoutParams(getWindowManager().getDefaultDisplay().getWidth(),getWindowManager().getDefaultDisplay().getHeight()));
        //web.setLayoutParams(new RelativeLayout.LayoutParams(getWindowManager().getDefaultDisplay().getWidth(),getWindowManager().getDefaultDisplay().getHeight()));
            }
            return false;

        }
    }); 

    }

}

```