blob: 2d0e8134a7c8897969a96ee7ecaa7b8909b74971 [file] [log] [blame]
Kirill Grouchnikovab89bf32016-01-19 14:01:51 -05001<?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<!-- Test layout for testing RTL-aware attributes on PercentRelativeLayout. Note that
18 we do not need to use layout_marginStartPercent *and* layout_marginLeftPercent
19 on the same child view to make it work correctly on different platform versions,
20 while we do have to use layout_alignParentEnd *and* layout_alignParentRight (as
21 the core RelativeLayout needs the old attribute on older pre-v17 platform versions).
22-->
23<android.support.percent.PercentRelativeLayout
24 xmlns:android="http://schemas.android.com/apk/res/android"
25 xmlns:app="http://schemas.android.com/apk/res-auto"
26 android:id="@+id/container"
27 android:layout_width="match_parent"
28 android:layout_height="match_parent">
29
30 <!-- This child is anchored along the top edge of the parent, testing percent-based
31 start margin, top margin and width, as well as the aspect ratio. -->
32 <View
33 android:id="@+id/child_top"
34 android:layout_alignParentTop="true"
35 android:layout_alignParentStart="true"
36 android:layout_alignParentLeft="true"
37 app:layout_widthPercent="50%"
38 app:layout_aspectRatio="2000%"
39 app:layout_marginStartPercent="20%"
40 app:layout_marginTopPercent="5%"
41 android:background="#5690E0" />
42
43 <!-- This child is anchored along the start edge of the parent, testing percent-based
44 start margin, top margin and height, as well as the aspect ratio. -->
45 <View
46 android:id="@+id/child_start"
47 android:layout_alignParentStart="true"
48 android:layout_alignParentLeft="true"
49 app:layout_heightPercent="50%"
50 app:layout_aspectRatio="5%"
51 app:layout_marginStartPercent="5%"
52 app:layout_marginTopPercent="20%"
53 android:background="#902030" />
54
55 <!-- This child is anchored along the bottom edge of the parent, testing percent-based
56 end margin, bottom margin and width, as well as the aspect ratio. -->
57 <View
58 android:id="@+id/child_bottom"
59 android:layout_alignParentBottom="true"
60 android:layout_alignParentRight="true"
61 android:layout_alignParentEnd="true"
62 app:layout_widthPercent="40%"
63 app:layout_aspectRatio="2000%"
64 app:layout_marginEndPercent="20%"
65 app:layout_marginBottomPercent="5%"
66 android:background="#A0B040" />
67
68 <!-- This child is anchored along the end edge of the parent, testing percent-based
69 end margin, bottom margin and height, as well as the aspect ratio. -->
70 <View
71 android:id="@+id/child_end"
72 android:layout_alignParentBottom="true"
73 android:layout_alignParentRight="true"
74 android:layout_alignParentEnd="true"
75 app:layout_heightPercent="40%"
76 app:layout_aspectRatio="5%"
77 app:layout_marginEndPercent="5%"
78 app:layout_marginBottomPercent="20%"
79 android:background="#20C0A0" />
80
81 <!-- This child is anchored to be in the "center" of the parent by anchoring it with
82 percent-based margins relatively to its edge-aligned siblings. -->
83 <View
84 android:id="@+id/child_center"
85 android:layout_width="match_parent"
86 android:layout_height="match_parent"
87 android:layout_below="@+id/child_top"
88 android:layout_toEndOf="@+id/child_start"
89 android:layout_toRightOf="@+id/child_start"
90 android:layout_toStartOf="@+id/child_end"
91 android:layout_toLeftOf="@+id/child_end"
92 android:layout_above="@+id/child_bottom"
93 app:layout_marginPercent="10%"
94 android:background="#F07020" />
95
96</android.support.percent.PercentRelativeLayout>
97