Kirill Grouchnikov | 059c122 | 2015-12-03 13:09:16 -0500 | [diff] [blame] | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <!-- Copyright (C) 2015 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.PercentFrameLayout |
| 18 | xmlns:android="http://schemas.android.com/apk/res/android" |
| 19 | xmlns:app="http://schemas.android.com/apk/res-auto" |
Kirill Grouchnikov | bcbbc06 | 2016-01-15 17:06:54 -0500 | [diff] [blame] | 20 | android:id="@+id/container" |
Kirill Grouchnikov | f7ad43b | 2016-01-06 16:19:17 -0500 | [diff] [blame] | 21 | android:layout_width="match_parent" |
Kirill Grouchnikov | 059c122 | 2015-12-03 13:09:16 -0500 | [diff] [blame] | 22 | android:layout_height="match_parent"> |
| 23 | |
Kirill Grouchnikov | f7ad43b | 2016-01-06 16:19:17 -0500 | [diff] [blame] | 24 | <!-- Note the usage of layout_gravity in all child views that use margin attributes that |
| 25 | addresses a bug in FrameLayout on v9 and older devices that didn't correctly treat the |
| 26 | margin attributes. --> |
| 27 | |
| 28 | <!-- For testing width + height only --> |
Kirill Grouchnikov | 059c122 | 2015-12-03 13:09:16 -0500 | [diff] [blame] | 29 | <View |
Kirill Grouchnikov | f7ad43b | 2016-01-06 16:19:17 -0500 | [diff] [blame] | 30 | android:id="@+id/child_width_height" |
| 31 | app:layout_widthPercent="50%" |
| 32 | app:layout_heightPercent="50%" /> |
| 33 | |
| 34 | <!-- For testing width + aspect ratio only --> |
| 35 | <View |
| 36 | android:id="@+id/child_width_ratio" |
| 37 | app:layout_widthPercent="60%" |
| 38 | app:layout_aspectRatio="120%" /> |
| 39 | |
| 40 | <!-- For testing height + aspect ratio only --> |
| 41 | <View |
| 42 | android:id="@+id/child_height_ratio" |
| 43 | app:layout_heightPercent="50%" |
| 44 | app:layout_aspectRatio="150%" /> |
| 45 | |
| 46 | <!-- For testing margins from a single attribute. Note that we still need core width / height |
| 47 | attributes since otherwise the logic in core FrameLayout will give size 0x0 to this |
| 48 | child. --> |
| 49 | <View |
| 50 | android:id="@+id/child_margins_single" |
| 51 | android:layout_width="match_parent" |
| 52 | android:layout_height="match_parent" |
| 53 | app:layout_marginPercent="30%" |
| 54 | android:layout_gravity="top" /> |
| 55 | |
| 56 | <!-- For testing margins from different attributes. Note that we still need core width / height |
| 57 | attributes since otherwise the logic in core FrameLayout will give size 0x0 to this |
| 58 | child. --> |
| 59 | <View |
| 60 | android:id="@+id/child_margins_multiple" |
| 61 | android:layout_width="match_parent" |
| 62 | android:layout_height="match_parent" |
| 63 | app:layout_marginTopPercent="10%" |
| 64 | app:layout_marginLeftPercent="15%" |
| 65 | app:layout_marginBottomPercent="20%" |
| 66 | app:layout_marginRightPercent="25%" |
| 67 | android:layout_gravity="top" /> |
| 68 | |
| 69 | <!-- For testing top + left margins with width + height --> |
| 70 | <View |
| 71 | android:id="@+id/child_margins_top_left" |
Kirill Grouchnikov | 059c122 | 2015-12-03 13:09:16 -0500 | [diff] [blame] | 72 | app:layout_widthPercent="50%" |
| 73 | app:layout_heightPercent="50%" |
| 74 | app:layout_marginTopPercent="20%" |
Kirill Grouchnikov | 2c889ec | 2015-12-07 18:10:05 -0500 | [diff] [blame] | 75 | app:layout_marginLeftPercent="20%" |
Kirill Grouchnikov | f7ad43b | 2016-01-06 16:19:17 -0500 | [diff] [blame] | 76 | android:layout_gravity="top|left" /> |
| 77 | |
| 78 | <!-- For testing bottom + right margin with width + height --> |
| 79 | <View |
| 80 | android:id="@+id/child_margins_bottom_right" |
| 81 | app:layout_widthPercent="60%" |
| 82 | app:layout_heightPercent="60%" |
| 83 | app:layout_marginBottomPercent="10%" |
| 84 | app:layout_marginRightPercent="10%" |
| 85 | android:layout_gravity="bottom|right" /> |
| 86 | |
| 87 | <!-- For testing start margin --> |
| 88 | <View |
| 89 | android:id="@+id/child_margin_start" |
| 90 | app:layout_widthPercent="50%" |
| 91 | app:layout_heightPercent="50%" |
| 92 | app:layout_marginStartPercent="20%" |
| 93 | android:layout_gravity="start" /> |
| 94 | |
| 95 | <!-- For testing end margin --> |
| 96 | <View |
| 97 | android:id="@+id/child_margin_end" |
| 98 | app:layout_widthPercent="50%" |
| 99 | app:layout_heightPercent="50%" |
| 100 | app:layout_marginEndPercent="30%" |
| 101 | android:layout_gravity="end" /> |
Kirill Grouchnikov | 059c122 | 2015-12-03 13:09:16 -0500 | [diff] [blame] | 102 | |
| 103 | </android.support.percent.PercentFrameLayout> |
| 104 | |