In xml you can do the following:
<TextView     ...     android:layout_centerHorizontal="true"     ... />   How would I, when I have the instance of TextView, do this programmatically?
You should use the addRule method of the RelativeLayout.LayoutParams class.     
layoutparams.addRule(RelativeLayout.CENTER_HORIZONTAL); mTextView.setLayoutParams(layoutParams); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With