1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (C) 2016 The Android Open Source Project
3
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7
8          http://www.apache.org/licenses/LICENSE-2.0
9
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15-->
16
17<android.support.percent.PercentRelativeLayout
18    xmlns:android="http://schemas.android.com/apk/res/android"
19    xmlns:app="http://schemas.android.com/apk/res-auto"
20    android:id="@+id/container"
21    android:layout_width="match_parent"
22    android:layout_height="match_parent">
23
24    <!-- This child is anchored along the top edge of the parent, testing percent-based
25         left margin, top margin and width, as well as the aspect ratio. -->
26    <View
27        android:id="@+id/child_top"
28        android:layout_alignParentTop="true"
29        app:layout_widthPercent="50%"
30        app:layout_aspectRatio="2000%"
31        app:layout_marginLeftPercent="20%"
32        app:layout_marginTopPercent="5%"
33        android:background="#5690E0" />
34
35    <!-- This child is anchored along the left edge of the parent, testing percent-based
36         left margin, top margin and height, as well as the aspect ratio. -->
37    <View
38        android:id="@+id/child_left"
39        android:layout_alignParentLeft="true"
40        app:layout_heightPercent="50%"
41        app:layout_aspectRatio="5%"
42        app:layout_marginLeftPercent="5%"
43        app:layout_marginTopPercent="20%"
44        android:background="#902030"  />
45
46    <!-- This child is anchored along the bottom edge of the parent, testing percent-based
47         right margin, bottom margin and width, as well as the aspect ratio. -->
48    <View
49        android:id="@+id/child_bottom"
50        android:layout_alignParentBottom="true"
51        android:layout_alignParentRight="true"
52        app:layout_widthPercent="40%"
53        app:layout_aspectRatio="2000%"
54        app:layout_marginRightPercent="20%"
55        app:layout_marginBottomPercent="5%"
56        android:background="#A0B040"  />
57
58    <!-- This child is anchored along the right edge of the parent, testing percent-based
59         right margin, bottom margin and height, as well as the aspect ratio. -->
60    <View
61        android:id="@+id/child_right"
62        android:layout_alignParentBottom="true"
63        android:layout_alignParentRight="true"
64        app:layout_heightPercent="40%"
65        app:layout_aspectRatio="5%"
66        app:layout_marginRightPercent="5%"
67        app:layout_marginBottomPercent="20%"
68        android:background="#20C0A0" />
69
70    <!-- This child is anchored to be in the "center" of the parent by anchoring it with
71         percent-based margins relatively to its edge-aligned siblings. -->
72    <View
73        android:id="@+id/child_center"
74        android:layout_width="match_parent"
75        android:layout_height="match_parent"
76        android:layout_below="@+id/child_top"
77        android:layout_toRightOf="@+id/child_left"
78        android:layout_toLeftOf="@+id/child_right"
79        android:layout_above="@+id/child_bottom"
80        app:layout_marginPercent="10%"
81        android:background="#F07020"  />
82
83</android.support.percent.PercentRelativeLayout>
84
85