java - Trying to change the Alignment of setText() method? -
i trying change alignment of "settext" method of "textview".to clear,on emulator i'm trying align set text of "settext".however unsuccessful in doing that.below posted code.
<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"/>
attached 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 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);
any suggestions helpful
text alginment doesn't take gravity constant. has own set. see http://developer.android.com/reference/android/view/view.html#settextalignment%28int%29 you're doing off.
generally right way either set layout_gravity of textview, or align textview way want, depending on size of string , effect you're trying get.
Comments
Post a Comment