Background
The content in the TextView shown in Android here is not in the middle of the level.
You want to align the horizontal center.
"Toss the process"
1. Search:
Android Relativelayout Horizontal Center
Reference:
Android–textview Horizontal Center in Relativelayout–stack Overflow
I tried it:
Android:layout_centerhorizontal= "true"
But it's useless.
2. Later saw:
Relativelayout–android Relative Layout Align center–stack Overflow
To try it:
Android:layout_centervertical= "true"
Just understand:
I was wrong to search the horizontal, in fact, to search vertical.
Now the effect is what you need:
Summary
To align horizontally, you only need to set:
Android:layout_centervertical= "true"
Can.
Extended
More other parameters, can go to the official website:
Relativelayout.layoutparams | Android Developers
Found in:
Attribute Name |
Related Method |
Description |
Android:layout_above |
Positions the bottom edge of this view above the given anchor view ID. |
Android:layout_alignbaseline |
Positions the baseline of this view on the baseline of the given anchor view ID. |
Android:layout_alignbottom |
Makes the bottom edge of this view match the bottom edge of the given anchor view ID. |
Android:layout_alignend |
Makes the end edge of this view match the end edge of the given anchor view ID. |
Android:layout_alignleft |
Makes the left edge of this view match the left edge of the given anchor view ID. |
Android:layout_alignparentbottom |
If true, makes the bottom edge of this view match the bottom edge of the parent. |
Android:layout_alignparentend |
If true, makes the end edge of this view match the end edge of the the parent. |
Android:layout_alignparentleft |
If true, makes the left edge of this view match the left edge of the parent. |
Android:layout_alignparentright |
If true, makes the right edge of this view match the right edge of the parent. |
Android:layout_alignparentstart |
If true, makes the start edge of this view match the start edge of the parent. |
Android:layout_alignparenttop |
If true, makes the top edge of this view match the top edge of the the parent. |
Android:layout_alignright |
Makes the right edge of this view match the right edge of the given anchor view ID. |
Android:layout_alignstart |
Makes the start edge of this view match the start edge of the given anchor view ID. |
Android:layout_aligntop |
Makes the top edge of this view match the top edge of the given anchor view ID. |
Android:layout_alignwithparentifmissing |
If set to True, the parent would be used as the anchor when the anchor cannot is be a found for Layout_toleftof, Layout_torig Htof, etc. |
Android:layout_below |
Positions the top edge of this view below the given anchor view ID. |
Android:layout_centerhorizontal |
If true, centers this child horizontally the within its parent. |
Android:layout_centerinparent |
If true, centers this child horizontally and vertically within its parent. |
Android:layout_centervertical |
If true, centers this child vertically the within its parent. |
Android:layout_toendof |
Positions the start edge of this view to the end of the given anchor view ID. |
Android:layout_toleftof |
Positions the right edge of this view to the left of the given anchor view ID. |
Android:layout_torightof |
Positions the left edge of this view to the right of the given anchor view ID. |
Android:layout_tostartof |
Positions the end edge of this view to the start of the given anchor view ID. |
As for each is what effect, you can go to try more on their own to know.
Relativelayout characters horizontally (vertically centered) aligned in Android