title: How to use layoutinflator to add views at runtime?
body: <p>I have two layouts: main.xml and buttonpanel.xml.  In buttonpanel.xml, in main linearlayout I set gravity to bottom.  Now i am trying to add the buttonpanel layout using the following code.</p>
  
  <pre><code>setContentView(R.layout.main);
  LinearLayout layout=(LinearLayout)findViewById(R.id.mainlinearlayout);
  LayoutInflater inflater= (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflater.inflate(R.layout.buttonpanel,null);
  layout.addView(view);
  </code></pre>
  
  <p>My problem is that the panel is added to the top though i have set gravity to bottom in buttonpanel.xml.  If I add buttonpanel.xml to main.xml using include it works fine.</p>
  
  <p>Can anyone help me what is the wrong with my code?</p>