android_manifest/layout.rs
1use serde::{Deserialize, Serialize};
2
3/// Affect how an activity behaves in multi-window mode.
4///
5/// With Android 7.0, the <layout> manifest element supports several attributes that
6/// affect how an activity behaves in multi-window mode:
7///
8/// ## Contained in
9/// * [`<activity>`]
10///
11/// [`<activity>`]: crate::Activity
12#[derive(
13 Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
14)]
15pub struct Layout {
16 /// Default width of the activity when launched in freeform mode.
17 #[yaserde(attribute, prefix = "android", rename = "defaultWidth")]
18 pub default_width: Option<String>,
19 /// Default height of the activity when launched in freeform mode.
20 #[yaserde(attribute, prefix = "android", rename = "defaultHeight")]
21 pub default_height: Option<String>,
22 /// Initial placement of the activity when launched in freeform mode. See the Gravity
23 /// reference for suitable values.
24 #[yaserde(attribute, prefix = "android")]
25 pub gravity: Gravity,
26 /// Minimum height and minimum width for the activity in both split-screen and
27 /// freeform modes. If the user moves the divider in split-screen mode to make an
28 /// activity smaller than the specified minimum, the system crops the activity to
29 /// the size the user requests.
30 ///
31 /// For example, the following code shows how to specify an activity's default size
32 /// and location, and its minimum size, when the activity is displayed in freeform
33 /// mode:
34 ///
35 /// ## XML Example
36 /// ```xml
37 /// <activity android:name=".MyActivity">
38 /// <layout android:defaultHeight="500dp"
39 /// android:defaultWidth="600dp"
40 /// android:gravity="top|end"
41 /// android:minHeight="450dp"
42 /// android:minWidth="300dp" />
43 /// </activity>
44 /// ```
45 #[yaserde(attribute, prefix = "android", rename = "minHeight")]
46 pub min_height: Option<String>,
47 /// Minimum height and minimum width for the activity in both split-screen and
48 /// freeform modes. If the user moves the divider in split-screen mode to make an
49 /// activity smaller than the specified minimum, the system crops the activity to
50 /// the size the user requests.
51 ///
52 /// For example, the following code shows how to specify an activity's default size
53 /// and location, and its minimum size, when the activity is displayed in freeform
54 /// mode:
55 ///
56 /// ## XML Example
57 /// ```xml
58 /// <activity android:name=".MyActivity">
59 /// <layout android:defaultHeight="500dp"
60 /// android:defaultWidth="600dp"
61 /// android:gravity="top|end"
62 /// android:minHeight="450dp"
63 /// android:minWidth="300dp" />
64 /// </activity>
65 /// ```
66 #[yaserde(attribute, prefix = "android", rename = "minWidth")]
67 pub min_width: Option<String>,
68}
69
70/// Standard constants and tools for placing an object within a potentially
71/// larger container.
72#[derive(Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Clone)]
73#[serde(rename_all = "camelCase")]
74#[derive(Default)]
75pub enum Gravity {
76 /// Raw bit controlling whether the right/bottom edge is clipped to its
77 /// container, based on the gravity direction being applied.
78 #[yaserde(rename = "axisClip")]
79 #[default]
80 AxisClip,
81 /// Raw bit controlling how the right/bottom edge is placed.
82 #[yaserde(rename = "axisPullAfter")]
83 AxisPullAfter,
84 /// Raw bit controlling how the left/top edge is placed.
85 #[yaserde(rename = "axisPullBefore")]
86 AxisPullBefore,
87 /// Raw bit indicating the gravity for an axis has been specified.
88 #[yaserde(rename = "axisSpecified")]
89 AxisSpecified,
90 /// Bits defining the horizontal axis.
91 #[yaserde(rename = "axisXShift")]
92 AxisXShift,
93 /// Bits defining the vertical axis.
94 #[yaserde(rename = "axisYShift")]
95 AxisYShift,
96 /// Push object to the bottom of its container, not changing its size.
97 #[yaserde(rename = "bottom")]
98 Bottom,
99 /// Place the object in the center of its container in both the vertical and
100 /// horizontal axis, not changing its size.
101 #[yaserde(rename = "center")]
102 Center,
103 /// Place object in the horizontal center of its container, not changing its
104 /// size.
105 #[yaserde(rename = "centerHorizontal")]
106 CenterHorizontal,
107 /// Place object in the vertical center of its container, not changing its
108 /// size.
109 #[yaserde(rename = "centerVertical")]
110 CenterVertical,
111 /// Flag to clip the edges of the object to its container along the
112 /// horizontal axis.
113 #[yaserde(rename = "clipHorizontal")]
114 ClipHorizontal,
115 /// Flag to clip the edges of the object to its container along the vertical
116 /// axis.
117 #[yaserde(rename = "clipVertical")]
118 ClipVertical,
119 /// Special constant to enable clipping to an overall display along the
120 /// horizontal dimension.
121 #[yaserde(rename = "displayClipHorizontal")]
122 DisplayClipHorizontal,
123 /// Special constant to enable clipping to an overall display along the
124 /// vertical dimension.
125 #[yaserde(rename = "displayClipVertical")]
126 DisplayClipVertical,
127 /// Push object to x-axis position at the end of its container, not changing
128 /// its size.
129 #[yaserde(rename = "end")]
130 End,
131 /// Grow the horizontal and vertical size of the object if needed so it
132 /// completely fills its container.
133 #[yaserde(rename = "fill")]
134 Fill,
135 /// Grow the horizontal size of the object if needed so it completely fills
136 /// its container.
137 #[yaserde(rename = "fillHorizontal")]
138 FillHorizontal,
139 /// Grow the vertical size of the object if needed so it completely fills
140 /// its container.
141 #[yaserde(rename = "fillVertical")]
142 FillVertical,
143 /// Binary mask to get the absolute horizontal gravity of a gravity.
144 #[yaserde(rename = "horizontalGravityMask")]
145 HorizontalGravityMask,
146 /// Push object to the left of its container, not changing its size.
147 #[yaserde(rename = "left")]
148 Left,
149 /// Constant indicating that no gravity has been set *
150 #[yaserde(rename = "noGravity")]
151 NoGravity,
152 /// Binary mask for the horizontal gravity and script specific direction
153 /// bit.
154 #[yaserde(rename = "relativeHorizontalGravityMask")]
155 RelativeHorizontalGravityMask,
156 /// Raw bit controlling whether the layout direction is relative or not
157 /// (START/END instead of absolute LEFT/RIGHT).
158 #[yaserde(rename = "relativeLayoutDirection")]
159 RelativeLayoutDirection,
160 /// Push object to the right of its container, not changing its size.
161 #[yaserde(rename = "right")]
162 Right,
163 /// Push object to x-axis position at the start of its container, not
164 /// changing its size.
165 #[yaserde(rename = "start")]
166 Start,
167 /// Push object to the top of its container, not changing its size.
168 #[yaserde(rename = "top")]
169 Top,
170 /// Binary mask to get the vertical gravity of a gravity.
171 #[yaserde(rename = "verticalGravityMask")]
172 VerticalGravityMask,
173}