title: how to set textview in CENTER dynamically
body: <p>In my code ,i want to set the text view in CENTER see this code pls ,tell me how to set </p>
  
  <p>i try ed this code but the date text view is not coming CENTER pls tell the changes  </p>
  
  <pre><code>    LinearLayout ll2=new LinearLayout(ctx);
      LayoutParams lp3=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
      ll2.setLayoutParams(lp3);
       ll2.setOrientation(LinearLayout.VERTICAL);
  
       LayoutParams lp2=null;
       LinearLayout ll4=new LinearLayout(ctx);
       lp2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  
       TextView tv2=new TextView(ctx);
       lp2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT);
  
      tv2.setLayoutParams(lp2);
      tv2.setText("MESSAGE");
      tv2.setBackgroundResource(R.drawable.rec);
       tv2.setTextSize(14);
       tv2.setTextColor(Color.parseColor("#5A3084"));
      if(sm!=null &amp;&amp; sm.message!=null)
          tv2.setText(sm.message.toString());
      tv2.setGravity(Gravity.LEFT);
      tv2.setPadding(10, 0, 10, 0);
  
      TextView tv0=new TextView(ctx);
  lp2=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
      tv0.setLayoutParams(lp2);
      tv0.setText("Alertdate :");
      tv0.setBackgroundResource(R.drawable.rec1);
      tv0.setTextColor(Color.parseColor("#38385E"));
      tv0.setGravity(Gravity.CENTER_VERTICAL);
  
  
  
  
       tv0.setTextSize(12);
      if(sm!=null &amp;&amp; sm.alertdate!=null)
  
          tv0.setText(sm.alertdate+"");
  </code></pre>