Recently saw a colleague wrote a piece of code, very simple is:
<linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android: Layout_centervertical= "true" android:orientation= "horizontal" android:gravity= "center_vertical" > <textview android:layout_width= "wrap_content" android:layout_height= "Wrap_content " Android:hint= "XXXXX" android:text= "x" /> <textview android:layout_width= "Wrap_ Content " android:layout_height=" wrap_content " android:textsize=" 16sp " android:text=" (x) " / > </LinearLayout>
The results shown are as follows:
Yes, the effect is this, two x there is a large gap between the beginning I thought it was the colleague set what, later looked at the XML did not see what, thought that is set minwidth, but also did not see, the key is to show the effect has a minimum length, find a half-day, finally realized hint this attribute, After setting the Hint property, the minimum width of the corresponding TextView will also be related to the length of the text you set, which is the final reason for this problem, so I want to say the end ...
The effect of Android:hint property on TextView