控件android:ems属性
本文地址:http://blog.csdn.net/caroline_wendy
xml中android:ems属性,作为EditText默认生成的属性,其含义是需要编辑的字符串长度。
设置为10时,最多编辑10个em,一个em单位是两个inch,但是随着自动调整,在Android中em代表‘M’的数量。
但是EditText的属性,只有在android:layout_width=“wrap_content”时,才会显示;
如果是android:layout_width=“match_parent”时,则不会有变化。
em参考:
http://www.w3.org/Style/Examples/007/units
“The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion. Declarations such as ‘text-indent: 1.5em‘ and ‘margin: 1em‘ are extremely common in CSS.”
ems属性参考:
参考:http://stackoverflow.com/questions/7053738/what-is-meant-by-ems-android-textview
android:ems or setEms(n) sets the width of a TextView to fit a text of n ‘M‘ letters regardless of the actual text extension and text size. See wikipedia Em unit. but only when the layout_width is set to "wrap_content". Other layout_width values override the ems width setting.
Adding an android:textSize attribute determines the physical width of the view to the textSize * length of a text of n ‘M‘s set above.