Android: Changing TextView Position (Left or Right) Programmatically?



My XML Layout's TextView's are positioned to be by default at the left hand side of the View.



<TextView
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:text="John Doe"
android:textColor="#040404"
android:typeface="sans"
android:textSize="15dip"
android:textStyle="bold"/>


How can I change the TextView position to be at the right hand side of the screen? I tried to do this using 'Gravity' but it doesn't change the position.


This is done from a GridView Adapter but I'm sure that doesn't affect anything. My code:



holder.comment.setGravity(Gravity.RIGHT);

No comments:

Post a Comment