title: Adding dynamic web views in android
body: <p>I am going through various links on this topic. I haven't found anything useful in my case. I want to create a <code>Web View</code> in Android dynamically. I will add nothing onto the xml layout file. 
  Now I want to do two things in particular:
   1. I want to set the size of this Web View to a custom width and height and set it at the bottom of the Layout.
   2. Once the page loads in the Web view. On click on the Web view should resize and go full screen(which means fill_parent on width and height for web view in its parent layout).</p>
  
  <p>My current code looks something like this below which does not work particularly well as the full screen does not fit the content to screen:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  
      RelativeLayout layout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          layout=(RelativeLayout)findViewById(R.id.test);
  
          final WebView web = new WebView(this);
  
          //web.setId(1);
          web.getSettings().setJavaScriptEnabled(true);
          web.loadData("&lt;script type=\"text/javascript\" src=\"http://www..myurl.com/myfolder/banner.php\"&gt;&lt;/script&gt;", null, null);
  
          layout.addView(web, new LayoutParams(300,100));
  
  
          web.setOnTouchListener(new OnTouchListener() {
  
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                  // TODO Auto-generated method stub
                  web.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
                  return false;
              }
          }); 
      }   
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>