I am new to the android application development. I am developing an application. While doing design for this app i am stuck in android:ems. What is this components.
-
Check this answer : http://stackoverflow.com/a/11177925/964741 – RajaReddy PolamReddy Nov 06 '15 at 03:51
-
Possible duplicate of [What is meant by Ems? (Android TextView)](http://stackoverflow.com/questions/7053738/what-is-meant-by-ems-android-textview) – user4232 Nov 06 '15 at 04:04
2 Answers
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.
em is basically CSS property for font sizes
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.
An em is a unit in the field of typography, equal to the currently specified point size.
More information about ems: wikipedia
More information about ems in Android doc
Makes the TextView exactly this many ems wide by using setEms (int ems)

- 111
- 1
- 7