| <?xml version="1.0" encoding="utf-8"?> |
| <!-- Copyright (C) 2016 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <!-- Test layout for testing RTL-aware attributes on PercentRelativeLayout. Note that |
| we do not need to use layout_marginStartPercent *and* layout_marginLeftPercent |
| on the same child view to make it work correctly on different platform versions, |
| while we do have to use layout_alignParentEnd *and* layout_alignParentRight (as |
| the core RelativeLayout needs the old attribute on older pre-v17 platform versions). |
| --> |
| <android.support.percent.PercentRelativeLayout |
| xmlns:android="http://schemas.android.com/apk/res/android" |
| xmlns:app="http://schemas.android.com/apk/res-auto" |
| android:id="@+id/container" |
| android:layout_width="match_parent" |
| android:layout_height="match_parent"> |
| |
| <!-- This child is anchored along the top edge of the parent, testing percent-based |
| start margin, top margin and width, as well as the aspect ratio. --> |
| <View |
| android:id="@+id/child_top" |
| android:layout_alignParentTop="true" |
| android:layout_alignParentStart="true" |
| android:layout_alignParentLeft="true" |
| app:layout_widthPercent="50%" |
| app:layout_aspectRatio="2000%" |
| app:layout_marginStartPercent="20%" |
| app:layout_marginTopPercent="5%" |
| android:background="#5690E0" /> |
| |
| <!-- This child is anchored along the start edge of the parent, testing percent-based |
| start margin, top margin and height, as well as the aspect ratio. --> |
| <View |
| android:id="@+id/child_start" |
| android:layout_alignParentStart="true" |
| android:layout_alignParentLeft="true" |
| app:layout_heightPercent="50%" |
| app:layout_aspectRatio="5%" |
| app:layout_marginStartPercent="5%" |
| app:layout_marginTopPercent="20%" |
| android:background="#902030" /> |
| |
| <!-- This child is anchored along the bottom edge of the parent, testing percent-based |
| end margin, bottom margin and width, as well as the aspect ratio. --> |
| <View |
| android:id="@+id/child_bottom" |
| android:layout_alignParentBottom="true" |
| android:layout_alignParentRight="true" |
| android:layout_alignParentEnd="true" |
| app:layout_widthPercent="40%" |
| app:layout_aspectRatio="2000%" |
| app:layout_marginEndPercent="20%" |
| app:layout_marginBottomPercent="5%" |
| android:background="#A0B040" /> |
| |
| <!-- This child is anchored along the end edge of the parent, testing percent-based |
| end margin, bottom margin and height, as well as the aspect ratio. --> |
| <View |
| android:id="@+id/child_end" |
| android:layout_alignParentBottom="true" |
| android:layout_alignParentRight="true" |
| android:layout_alignParentEnd="true" |
| app:layout_heightPercent="40%" |
| app:layout_aspectRatio="5%" |
| app:layout_marginEndPercent="5%" |
| app:layout_marginBottomPercent="20%" |
| android:background="#20C0A0" /> |
| |
| <!-- This child is anchored to be in the "center" of the parent by anchoring it with |
| percent-based margins relatively to its edge-aligned siblings. --> |
| <View |
| android:id="@+id/child_center" |
| android:layout_width="match_parent" |
| android:layout_height="match_parent" |
| android:layout_below="@+id/child_top" |
| android:layout_toEndOf="@+id/child_start" |
| android:layout_toRightOf="@+id/child_start" |
| android:layout_toStartOf="@+id/child_end" |
| android:layout_toLeftOf="@+id/child_end" |
| android:layout_above="@+id/child_bottom" |
| app:layout_marginPercent="10%" |
| android:background="#F07020" /> |
| |
| </android.support.percent.PercentRelativeLayout> |
| |