<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="17dp" android:background="#00ffff" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:textColor="?attr/text_color_black_academia" android:textSize="17sp" android:text="@string/test" /> </RelativeLayout>
The result of this layout display:
Then, wrap a LinearLayout in the outer layer of the RelativeLayout, namely:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#00ff00" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="17dp" android:background="#00ffff" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:textColor="?attr/text_color_black_academia" android:textSize="17sp" android:text="@string/test" /> </RelativeLayout> </LinearLayout>
The result displayed at this time is:
This is the problem, but I still don't quite understand how it is. It is worth noting that the android:layout_centerVertical="true" attribute of TextView is the core of the problem, because if this attribute is removed, it can be displayed normally.