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!
Relative xml layout portion
<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">
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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">
<!--<TextView--> (Want to replace this part with programmatic creation)
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:gravity="center"-->
<!--android:textSize="20dp"-->
<!--android:text="Welcome to Central Park!" />-->
</LinearLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<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" />
<LinearLayout
android:id="@+id/view_pager_countDots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" />
<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=">"
android:textSize="30dp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Java 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);