宽度为10个字符的宽度

xml中 android:ems属性 ,作为EditText 默认生成 的属性,其含义是需要编辑的 字符串长度 。
设置为10时,最多编辑 10个em ,一个em单位是 两个inch ,但是随着自动调整,在Android中 em代表‘M’的数量 。
但是 EditText的属性 ,只有在 android:layout_width=“wrap_content” 时,才会显示;
如果是 android:layout_width=“match_parent” 时,则不会有变化。

android:ems

Makes the TextView be exactly this many ems wide.

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol ems.

使这个TextView恰好有many个ems宽度。

必须是整数值,如“100”。

这个值可以引用资源(以"@[package:]type:name"的形式)或者包含这个类型的值的主题属性(以"?[package:][type:]name"的形式)

这对应全球资源属性符号ems。

android:maxEms

Makes the TextView be at most this many ems wide.

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol maxEms.

使这个TextView最多可以有many个ems宽度。


实例1:

    <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxEms="4"
android:ems="2"
android:text="一二三四五六七八九十" />
结果:
android:layout_width="match_parent"使得android:maxEms和android:ems无效。

实例2:
    <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxEms="4"
android:text="一二三四五六七八九十" />
结果:

实例3:

    <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="6"
android:text="一二三四五六七八九十" />
结果:

实例4:

    <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="6"
android:maxEms="4"
android:text="一二三四五六七八九十" />
结果:
android:ems覆盖android:maxEms属性。

问题:

    <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"
android:text="一二三四五六七八九十" />

结果:正常猜想是显示到8就好了。但结果是显示到了9。

API显示是恰好many个ems宽度。

那这里需要了解一下ems这个单位。

em是一个印刷排版的单位,表示字宽的单位。 em字面意思为:equal M   (和M字符一致的宽度为一个单位)简称em。

ems是em的复数表达。

https://en.wikipedia.org/wiki/Em_%28typography%29

设置为10时,最多编辑 10个em ,一个em单位是 两个inch ,但是随着自动调整(相对单位),在Android中 em代表‘M’的数量 。

结论:该属性是以ems为单位,不是以字符为单位。至于ems和字符之间的关系,还没有了解。正常也很少用这玩意。

android xml 布局文件中 android:ems="10"的更多相关文章

  1. android xml布局文件中tools:layout的作用

    摘要 用最新版本的adt 创建一个基于master/detail flow 模版的app的时候,生成的 activity_item_list.xml 文件中有一个tools:layout属性: fra ...

  2. (转载)Android xml资源文件中@、@android:type、@*、?、@+引用写法含义以及区别

    原帖地址:http://blog.csdn.net/zfrong/article/details/7332545 Android xml资源文件中@.@android:type.@*.?.@+引用写法 ...

  3. Android Fragment之间的通信(用fragment替换掉XML布局文件中的一个线性布局)

    1.XML布局 (1)主界面 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xml ...

  4. 通过在xml布局文件中设置android:onClick=""来实现组件单击事件

    在布局中出现android:onClick=""语句: <Button android:id="@+id/call_button" android:onC ...

  5. Android xml资源文件中@、@android:type、@*、?、@+含义和区别

    一.@代表引用资源 1.引用自定义资源.格式:@[package:]type/name android:text="@string/hello" 2.引用系统资源.格式:@andr ...

  6. 【转】Android xml资源文件中@、@android:type、@*、?、@+含义和区别

    一.@代表引用资源 1.引用自定义资源.格式:@[package:]type/name android:text="@string/hello" 2.引用系统资源.格式:@andr ...

  7. Android:关于声明文件中android:process属性说明

    笔者在学习Android Service组件的过程中碰到了一个问题,就是在Android应用的声明文件Manifest.xml中有时候会对相关的服务标签设置一个android:process=&quo ...

  8. android布局文件中android:icon="?attr/menuIconCamera"找不到对应图标路径

    如 <item android:id="@+id/camera" android:title="Camera" android:icon="?a ...

  9. Android中measure过程、WRAP_CONTENT详解以及 xml布局文件解析流程浅析

    转自:http://www.uml.org.cn/mobiledev/201211221.asp 今天,我着重讲解下如下三个内容: measure过程 WRAP_CONTENT.MATCH_PAREN ...

随机推荐

  1. 一些优秀的SLAM博主

    http://blog.csdn.net/u010566411 http://blog.csdn.net/qq_18661939/article/details/51782376 http://www ...

  2. KMP与循环节相关题目

    HDU 3746 Cyclic Nacklace ( KMP求最小循环节 ) len - nextval[len]即为最小循环节长度. #include <cstdio> #include ...

  3. HDU 4747 Mex ( 线段树好题 + 思路 )

    参考:http://www.cnblogs.com/oyking/p/3323306.html 相当不错的思路,膜拜之~ 个人理解改日补充. #include <cstdio> #incl ...

  4. python与MySQL数据库

    python与MySQL数据库 慕课网连接 我使用的软件:python2.7 + MySQL+ Navicat for MySQL + Atom 注意:你的数据库表格类型的引擎为:InnoDB :字符 ...

  5. EK算法模板

    #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> ...

  6. SQL视频总结

    SQL是英文Structured Query Language的缩写,意思为结构化查询语言. SQL语言的主要功能就是同各种数据库建立联系,进行沟通.SQL被作为关系型数据库管理系统的标准语言. SQ ...

  7. BZOJ1023[SHOI2008]cactus仙人掌图 【仙人掌DP】

    题目 如果某个无向连通图的任意一条边至多只出现在一条简单回路(simple cycle)里,我们就称这张图为仙人掌 图(cactus).所谓简单回路就是指在图上不重复经过任何一个顶点的回路. 举例来说 ...

  8. 【HDU 2594 Simpsons' Hidden Talents】

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...

  9. 【CZY选讲·吃东西】

    题目描述 一个神秘的村庄里有4家美食店.这四家店分别有A,B,C,D种不同的美食.LYK想在每一家店都吃其中一种美食.每种美食需要吃的时间可能是不一样的.现在给定第1家店A种不同的美食所需要吃的时间 ...

  10. 用IE滤镜实现的一些特效

    CSS3是当下非常火的一个话题,很多浏览器都已经开始支持这一特性,然后IE这个拥有庞大用户群体的平台,却无法提供这样的支持,即便是IE9发布,也无法改变这一事实,然而,幸运的是,IE并非在这方面毫无作 ...