title: Creating a TextView programmatically
body: <p>I am trying to create a TextView programmatically as shown in the image on the left side， but I'm out of luck. For some reason, the "SKIP" and ">" gets duplicated in two rows as shown in the image on the right side. I attach my relative code below for reference. Note that the left image is done with a static xml layout. The reason to create the TextView programmatically is because I need to replace the TextView with a button at the 4th slide. Please help!</p>
  
  <p>Relative xml layout portion</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/view_pager_indicator"
      android:layout_width="match_parent"
      android:layout_height="100dp"
      android:layout_alignParentBottom="true"
      android:layout_marginTop="5dp"
      android:layout_marginBottom="24dp"
      android:gravity="center"&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:gravity="center"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;LinearLayout
              android:id="@+id/pager_info"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:gravity="center"
              android:layout_marginBottom="20dp"&gt;
  
  &lt;!--&lt;TextView--&gt; (Want to replace this part with programmatic creation)
                  &lt;!--android:layout_width="wrap_content"--&gt;
                  &lt;!--android:layout_height="wrap_content"--&gt;
                  &lt;!--android:gravity="center"--&gt;
                  &lt;!--android:textSize="20dp"--&gt;
                  &lt;!--android:text="Welcome to Central Park!" /&gt;--&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;RelativeLayout
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"&gt;
  
              &lt;TextView
                  android:id="@+id/btn_skip"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="15dip"
                  android:gravity="left"
                  android:text="SKIP"
                  android:textSize="20dp" /&gt;
  
              &lt;LinearLayout
                  android:id="@+id/view_pager_countDots"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:gravity="center"
                  android:orientation="horizontal" /&gt;
  
              &lt;TextView
                  android:id="@+id/btn_next"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginRight="15dip"
                  android:gravity="right"
                  android:text="&gt;"
                  android:textSize="30dp" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Java code</p>
  
  <pre><code>pager_info = (LinearLayout) view.findViewById(R.id.pager_info);
  TextView msg = new TextView(MyActivity.this);
  msg.setText(message[0]);
  msg.setTextSize(16);
  msg.setLayoutParams(new LinearLayout.LayoutParams(
      new LayoutParams(LayoutParams.MATCH_PARENT,
      LayoutParams.WRAP_CONTENT)));
  msg.setGravity(Gravity.CENTER);
  pager_info.addView(msg);
  </code></pre>