RTL布局

当我们需要支持阿拉伯语等右左UI布局时,我们就要考虑RTL Layout了。


1.在AndroidManifest.xml中设置:

android:supportsRtl="true"

2.当我们只想要支持RTL布局时,可以在xml布局中设置:

android:layoutDirection="rtl"

此时,布局就是右左顺序显示了

3.当我们需要同时支持LTR和RTL呢?那就需要用几个特殊属性了

android:paddingLeft --> android:paddingStart

android:paddingRight --> android:paddingEnd

android:layout_marginLeft --> android:layout_marginStart

android:layout_marginRight --> android:layout_marginEnd

android:layout_alignParentLeft --> android:layout_alignParenStart

扫描二维码关注公众号,回复: 2085813 查看本文章

android:layout_alignParentLeft --> android:layout_alignParenEnd

android:layout_toLeftof --> android:layout_toStartof

android:layout_toRightof --> android:layout_toEndof

说明:

android:layout_marginStart:如果在LTR布局模式下,该属性等同于android:layout_marginLeft。如果在RTL布局模式下,该属性等同于android:layout_marginRight。

android:layout_marginEnd:如果在LTR布局模式下,该属性等同于android:layout_marginRight。

如果在RTL布局模式下,该属性等同于android:layout_marginLeft。

其他几个同理!




猜你喜欢

转载自blog.csdn.net/fwt336/article/details/79460921
今日推荐