宽度为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. php天龙八部

    <?php /* 一.操作步骤: 连接MySQL数据库 判断是否连接成功 选择数据库 设置字符集 准备SQL语句 向MySQL服务发送SQL语句 解析处理结果集 释放结果集,关闭数据库连接 */ ...

  2. .NET Framework中的过时类型

    文章:.NET Framework 中的过时类型 url地址:https://docs.microsoft.com/zh-cn/dotnet/framework/whats-new/obsolete- ...

  3. 201621123033 《Java程序设计》第9周学习总结

    第九次作业 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 1.2 选做:收集你认为有用的代码片段 //stream(),filter(),collect() ...

  4. Linux下nginx支持.htaccess文件实现伪静态的方法!

    在Google上搜索的资料很多人都说nginx目前不支持.htaccess文件,我按照nginx的规则试验了一下,结果发现nginx是完全支持.htaccess文件的! 方法如下: 1. 在需要使用. ...

  5. Multiplication Game(博弈论)

    Description Alice and Bob are in their class doing drills on multiplication and division. They quick ...

  6. mac平台打造犀利的Android Studio开发环境

    0x0 背景介绍  随着Android Studio功能越来越强大,Android平台的开发者们基本上都从原来的Eclipse + ADT 转到了AS上.本文就记录自己在配置AS环境过程中遇到的各种问 ...

  7. Eclipse Tomcat 配置问题

    问题描述: Tomcat能启动,ecplise的Console无报错,但是打开http://localhost:8080/报404错误 端口是8080没错,地址也没错,重启了tomcat还是报错,但是 ...

  8. Gradle for Android(三)多渠道打包、配置签名信息

    多渠道打包 国内有太多Android App市场,每次发版几十个渠道包.还好Android Gradle给我们提供了productFlavors,我们可以对生成的APK包进行定制. productFl ...

  9. 云服务器基本环境配置(php5.6+mysql+nginx)

    1.安装nginx sudo apt-get install nginx nginx 基本配置 server{ listen ; server_name www.xxxxxx.cn; root /va ...

  10. [bzoj1051][HAOI2006]受欢迎的牛——强连通分量

    题目大意: 给定一个有向图,求能够被其他所有点访问到的点的个数. 题解: 首先,这个题我在洛谷上AC了,但是bzoj上WA,不知道为什么. 说一下解法. 首先,我们进行scc分解,可以知道, 如果一个 ...