原文地址:http://blog.csdn.net/aa464971/article/details/51372204


Android Studio新建工程的AndroidManifest文件里会有一个supportsRtl属性,并且默认是true,那这个属性到底有什么用呢,顾名思义就是“支持RTL”,那RTL又是神马鬼

带着这个问题去翻了翻Android官网的文档

这是官网对android:supportsRtl的解释,英文不太好只能用工具和自己的理解翻译一下

官网原文链接:http://developer.android.com/intl/zh-cn/guide/topics/manifest/application-element.html

android:supportsRtl

Declares whether your application is willing to support right-to-left (RTL) layouts.

If set to true and targetSdkVersion is set to 17 or higher, various RTL APIs will be activated and used by the system so your app can display RTL layouts. If set to false or if targetSdkVersion is set to 16 or lower, the RTL

APIs will be ignored or will have no effect and your app will behave the same regardless of the layout direction ass ociated to the user's Locale choice (your layouts will always be left-to-right).

The default value of this attribute is false.

This attribute was added in API level 17.

声明你的application是否愿意支持从右到左(原来RTL就是right-to-left 的缩写...)的布局。

如果设置为true,targetSdkVersion设置为17或更高,各种RTL的API将被激活,系统使用您的应用程序可以显示RTL布局。如果targetSdkVersion设置为16或更低的设置为false,RTL的API将被忽略或没有影响您的应用程序将具有相同的行为无论对用户现场的选择相关的布局方向(你的布局会从左至右)。

此属性的默认值是false。

此属性被添加到API 17。

最后一句也说了,这个api是17(也就是Android4.2)以后才有的,并且这个属性默认是false,17以前的api不支持这个属性。

那这个支持从右到左的布局到底是个什么鬼呢。

经常玩机的朋友应该有发现,在设置-开发人员选项,有一个强制使用从右到左的布局方向,如图

(转)Android AndroidManifest.xml文件的android:supportsRtl属性详解_第1张图片

既然有这么个东西,那就打开看看

(转)Android AndroidManifest.xml文件的android:supportsRtl属性详解_第2张图片

打开之后变成这样了,原先在左边的文字被放到右边去了,在右边的开关,也被放到左边了,看到这个就明白了这个属性的意思了吧

为了证明这个属性,再弄个demo试试

当android:supportsRtl为false的时候,即使手机开启了强制从右到左,app的布局也不会改变,如图

(转)Android AndroidManifest.xml文件的android:supportsRtl属性详解_第3张图片

当android:supportsRtl为true的时候,并且手机也开启了强制从右到左的开关,那么布局就会从右到左来排列了,如图

(转)Android AndroidManifest.xml文件的android:supportsRtl属性详解_第4张图片

更多相关文章

  1. Android 布局之TableLayout
  2. Android的多语言文件转IOS多语言文件格式
  3. Android 自动编译、打包生成apk文件 1 - 命令行方式
  4. 由Android4.4收起写sdcard文件权限想到的.
  5. Android布局属性介绍
  6. 简解selector的几个属性
  7. 五大布局-----FrameLayout帧布局
  8. android一些有用的View属性

随机推荐

  1. Android(安卓)Studio快速添加Gson以及Gso
  2. Android开发学习之TypedArray类
  3. Android(安卓)全局沉浸式显示效果
  4. 翻译Android(安卓)API Guides: App Manif
  5. FFmpeg学习—android 编译libfaac 音频库
  6. 最近下载了ADT Version 22发现里面多了个
  7. android studio 新建class文件报错Unable
  8. Android(安卓)结束进程的方法
  9. Android(安卓)多次点击事件的触发方法
  10. android 常用第三方插件收藏