您的位置:首页 > 产品设计 > UI/UE

一个demo掌握Android Manifest文件的android:supportsRtl="true"属性(7.22)

2017-07-19 10:39 302 查看
supportsRtl ==>  supports right to lift  

是否支持 从右到左的布局(主要是方便从右到左的阅读习惯)

官网注解 :

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 associated 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.

开发者选项中的开关如下 :



布局代码如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.ufotosoft.demo.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LinearLayout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:background="#f5dfc5">
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#ef8057"
android:text="1"
/>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#efbf57"
android:text="2"

/>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#efe757"
android:text="3"

/>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#85ef57"
android:text="4"

/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LinearLayout gravity right" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:gravity="right"
android:background="#f5dfc5">
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#ef8057"
android:text="1"
/>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#efbf57"
android:text="2"
/>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#efe757"
android:text="3"

/>
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:background="#85ef57"
android:text="4"

/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RelativeLayout" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#f5dfc5">
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="#ef8057"
android:text="1"

/>
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="#efbf57"
android:text="2"

/>
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#efe757"
android:text="3"

/>
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#85ef57"
android:text="4"

/>
</RelativeLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FrameLayout" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#f5dfc5">
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="#ef8057"
android:text="1"

/>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TableLayout" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="#ef8057"
android:text="1"
/>
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="#efbf57"
android:text="2"
/>
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#efe757"
android:text="3"
/>

</TableLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GridLayout" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:columnCount="3"
android:rowCount="3"
>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="#ef8057"
android:text="1"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="#efbf57"
android:text="2"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#efe757"
android:text="3"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#85ef57"
android:text="4"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="#ef8057"
android:text="5"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="#efbf57"
android:text="6"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#efe757"
android:text="7"
/>
<TextView
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#85ef57"
android:text="8"
/>
</GridLayout>
</LinearLayout>


开关关闭时效果 :



开关打开时效果 (manifest application 设置 android:supportsRtl="true")



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: