<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_height= "Match_parent"Android:layout_width= "Match_parent" > <TextViewAndroid:layout_alignparentleft= "true"Android:text= "@string/set_label_local_albums"Android:layout_height= "Wrap_content"<!--If it's set to Wrap_content.
Android:layout_width= "Match_parent"Android:paddingtop= "33DP"Android:paddingleft= "21DP"Android:textcolor= "@color/action_bar_title_text_color"android:textsize= "@dimen/action_bar_title_text_size" /></Relativelayout>
Today, when I changed Actionbartab, I met a very strange thing, that is, when I customize a layout (as above), no matter how I adjust, TextView always has a position in the middle of the distance, although I set the relativelayout is full of the parent container. Looking at the layout through hierarchy, you will find that the relativelayout is the same width as the textview. How to test it later.
Then I thought, since both of them are the same, then if I have to set the two controls separately, the width is different. Then I set the two widths to 178DP, respectively, and the results really took effect. This concludes that TextView decides everything and must set the width of the two controls to match_parent to achieve the effect
Android-actionbartab custom layouts cannot change the position of the font relative to the middle