RTL模式简介
来源:互联网 发布:淘宝店铺起名 编辑:程序博客网 时间:2024/06/16 01:12
RTL介绍
Right To Left,是一种阿拉伯语、波斯语等情况下从右往左的阅读方式。当所开发的App等面向海外用户时需要做这个适配
在开发者选项中,打开以下设置即可
如何支持RTL
1、需要在清单文件总队RTL的支持做一个声明,放到< application >节点下
2、将布局中的”left、right“相关的属性换成对应的”start、end“属性
栗子:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:id="@+id/parent" > <Button android:id="@+id/button" android:text="A" android:layout_width="60dp" android:layout_height="40dp" /> <Button android:id="@+id/button2" android:text="B" android:layout_toRightOf="@id/button" android:layout_width="60dp" android:layout_height="40dp" /> <Button android:id="@+id/button3" android:text="C" android:layout_toRightOf="@id/button2" android:layout_width="60dp" android:layout_height="40dp" /></RelativeLayout>
正常情况下的效果
RTL模式下效果
为什么B、C按钮不见了?因为根据属性,它们都在A的右边,这已经超出的屏幕边界
修改如下:
<Button android:id="@+id/button2" android:text="B" android:layout_toRightOf="@id/button" android:layout_toEndOf="@id/button" android:layout_width="60dp" android:layout_height="40dp" /> <Button android:id="@+id/button3" android:text="C" android:layout_toRightOf="@id/button2" android:layout_toEndOf="@id/button2" android:layout_width="60dp" android:layout_height="40dp" />
这回再看RTL下效果
页面不想支持RTL怎么办
有一些界面你不想它支持RTL,或者它本身不需要支持,那又该如何呢?比如说拨号界面,难道要把数字键也镜像过去吗?
只需要加上这么一句
layoutDirect可以使用4种属性:ltr:从左往右rtl:从右往左inherit:从上层视图中继承locale:由Locale决定分别对应的int值为0,1,2,3
图片处理
正常情况下效果
RTL下效果
其实像箭头这种图片应该反过来的:
只需要创建一个文件夹,把镜像后的图片放进去即可,代码中不用做任何修改:
分辨率是一一对应的
阅读全文
0 0
- RTL模式简介
- vcs rtl tool 简介
- Android 开发之布局细节对比:RTL模式
- Android 开发:如何让App支持RTL模式
- rtl code
- RTL布局
- 模式简介
- RTL中文版(zz)
- RTL Compiler (1)
- delphi運行時間庫RTL
- Can C beat RTL?
- 集成电路 RTL 设计
- RTL内存函数
- RTL代码风格
- RTL级 门级
- android的RTL支持
- RtlZeroMemory中的Rtl是什么意思
- rtl-ui-2
- PHP unset()函数销毁变量
- android 图片圆角处理
- 内域和外域
- 使用Masonry动态设置tableview表头---tableHeaderView(解决表头背景色设置不了问题)
- 【头条】企业云安全防御存在“软肋” 赛门铁克给出应对策略
- RTL模式简介
- Java socket报文通信(一)socket的建立
- 【Jsoup】配合 htmlunit 爬取异步加载的网页
- nginx配置自动转https站点
- javascrpit 面试题收集
- JavaScript是如何工作的:内存管理 + 如何处理4个常见的内存泄露
- docker compose
- HTML杂记
- Spring自定义注解+Aop记录用户操作日志