I've been attempting to adjust the alignment of the "setText" method in a "TextView". Specifically, on my emulator, I'm trying to set the text alignment using the "setText" method. Unfortunately, I haven't been successful in accomplishing this task. Below is the code snippet that I have been working with:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#ff00ff"
android:text="@string/username"
android:background="#00ff00"
android:id="@+id/text1"
android:textColorHighlight="#000000"
android:textIsSelectable="true"
android:textAlignment="center"
android:layout_alignParentTop="true"/>
Here is the accompanying Java code:
TextView t1, t2;
t1 = (TextView) findViewById(R.id.text1);
System.out.println(t1.toString());
tableRow = new TableRow(getApplicationContext());
t1 = new TextView(getApplicationContext());
t1.setText("Username");
t1.setTextSize(20);
t1.setTextAlignment(Gravity.BOTTOM); //This is where I'm facing issues!
t1.setTextColor(Color.RED);
t1.setTypeface(null, Typeface.BOLD);
t1.setPadding(15, 35, 15, 15);
t1.setAllCaps(true);
t1.setBackgroundResource(R.drawable.cellgrey);
tableRow.addView(t1);
Any advice or suggestions would be greatly appreciated.