0
我試圖改變「TextText」的「setText」方法的對齊方式。要清楚,在我的模擬器上,我試圖對齊設置「setText」的文本。但是,我沒有成功做到這一點。是我的代碼。試圖更改setText()方法的對齊方式?
<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"/>
附件是Java代碼
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 what I'm trying!!
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);
任何建議將是有益的