title: how i set layout_gravity in java file
body: <p>I want to set layout in Java code file. I use the following code to set this <code>layout</code> to center</p>
  
  <pre><code>        theme = db.getthemeByID(id);
          String themePath = theme.getFilepath();
          int resid = getResources().getIdentifier(themePath, "drawable", getPackageName());
          //layout for book theme
          LinearLayout LLT = new LinearLayout(context);
          LLT.setOrientation(LinearLayout.VERTICAL);
      &gt;&gt;&gt;&gt;LLT.setLayoutParams(new LayoutParams(500, 650, Gravity.CENTER_HORIZONTAL));
          LLT.setBackgroundResource(resid);   
          // add view 
          VF.addView(LLT);
  </code></pre>
  
  <p>I'm still getting error on this line: </p>
  
  <p><code>LLT.setLayoutParams(new LayoutParams(500, 650, Gravity.CENTER_HORIZONTAL));</code></p>
  
  <p>How can I do if I want to set <code>layout</code> to <code>center_horizontal</code></p>