• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
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 package com.android.ide.common.layout;
18 
19 import static com.android.ide.eclipse.adt.AdtConstants.ANDROID_PKG;
20 
21 import com.android.sdklib.SdkConstants;
22 
23 /**
24  * A bunch of constants that map to either:
25  * <ul>
26  * <li>Android Layouts XML element names (Linear, Relative, Absolute, etc.)
27  * <li>Attributes for layout XML elements.
28  * <li>Values for attributes.
29  * </ul>
30  */
31 public class LayoutConstants {
32     /** The element name in a {@code <view class="...">} element. */
33     public static final String VIEW = "view";                           //$NON-NLS-1$
34 
35     /** The attribute name in a {@code <view class="...">} element. */
36     public static final String ATTR_CLASS = "class";                    //$NON-NLS-1$
37     public static final String ATTR_ON_CLICK = "onClick";               //$NON-NLS-1$
38     public static final String ATTR_TAG = "tag";                        //$NON-NLS-1$
39     public static final String ATTR_NUM_COLUMNS = "numColumns";         //$NON-NLS-1$
40     public static final String ATTR_PADDING = "padding";                //$NON-NLS-1$
41 
42     // Some common layout element names
43     public static final String RELATIVE_LAYOUT = "RelativeLayout";      //$NON-NLS-1$
44     public static final String LINEAR_LAYOUT   = "LinearLayout";        //$NON-NLS-1$
45     public static final String ABSOLUTE_LAYOUT = "AbsoluteLayout";      //$NON-NLS-1$
46     public static final String TABLE_LAYOUT = "TableLayout";            //$NON-NLS-1$
47     public static final String TABLE_ROW = "TableRow";                  //$NON-NLS-1$
48     public static final String CALENDAR_VIEW = "CalendarView";          //$NON-NLS-1$
49     public static final String LIST_VIEW = "ListView";                  //$NON-NLS-1$
50     public static final String EDIT_TEXT = "EditText";                  //$NON-NLS-1$
51     public static final String GALLERY = "Gallery";                     //$NON-NLS-1$
52     public static final String GRID_LAYOUT = "GridLayout";              //$NON-NLS-1$
53     public static final String GRID_VIEW = "GridView";                  //$NON-NLS-1$
54     public static final String SPINNER = "Spinner";                     //$NON-NLS-1$
55     public static final String SCROLL_VIEW = "ScrollView";              //$NON-NLS-1$
56     public static final String RADIO_BUTTON = "RadioButton";            //$NON-NLS-1$
57     public static final String RADIO_GROUP = "RadioGroup";              //$NON-NLS-1$
58     public static final String SPACE = "Space";                         //$NON-NLS-1$
59     public static final String EXPANDABLE_LIST_VIEW = "ExpandableListView";//$NON-NLS-1$
60     public static final String GESTURE_OVERLAY_VIEW = "GestureOverlayView";//$NON-NLS-1$
61     public static final String HORIZONTAL_SCROLL_VIEW = "HorizontalScrollView"; //$NON-NLS-1$
62 
63     public static final String ATTR_CONTENT_DESCRIPTION = "contentDescription"; //$NON-NLS-1$
64     public static final String ATTR_TEXT = "text";                      //$NON-NLS-1$
65     public static final String ATTR_HINT = "hint";                      //$NON-NLS-1$
66     public static final String ATTR_ID = "id";                          //$NON-NLS-1$
67     public static final String ATTR_INPUT_TYPE = "inputType";           //$NON-NLS-1$
68     public static final String ATTR_STYLE = "style";                    //$NON-NLS-1$
69     public static final String ATTR_HANDLE = "handle";                  //$NON-NLS-1$
70     public static final String ATTR_CONTENT = "content";                //$NON-NLS-1$
71     public static final String ATTR_CHECKED = "checked";                //$NON-NLS-1$
72     public static final String ATTR_BACKGROUND = "background";          //$NON-NLS-1$
73 
74     public static final String ATTR_LAYOUT_PREFIX = "layout_";          //$NON-NLS-1$
75     public static final String ATTR_LAYOUT_HEIGHT = "layout_height";    //$NON-NLS-1$
76     public static final String ATTR_LAYOUT_WIDTH = "layout_width";      //$NON-NLS-1$
77     public static final String ATTR_LAYOUT_GRAVITY = "layout_gravity";  //$NON-NLS-1$
78     public static final String ATTR_LAYOUT_WEIGHT = "layout_weight";    //$NON-NLS-1$
79 
80     public static final String ATTR_LAYOUT_MARGIN = "layout_margin";               //$NON-NLS-1$
81     public static final String ATTR_LAYOUT_MARGIN_LEFT = "layout_marginLeft";      //$NON-NLS-1$
82     public static final String ATTR_LAYOUT_MARGIN_RIGHT = "layout_marginRight";    //$NON-NLS-1$
83     public static final String ATTR_LAYOUT_MARGIN_TOP = "layout_marginTop";        //$NON-NLS-1$
84     public static final String ATTR_LAYOUT_MARGIN_BOTTOM = "layout_marginBottom";  //$NON-NLS-1$
85 
86     // TextView
87     public static final String ATTR_DRAWABLE_RIGHT = "drawableRight";              //$NON-NLS-1$
88     public static final String ATTR_DRAWABLE_LEFT = "drawableLeft";                //$NON-NLS-1$
89     public static final String ATTR_DRAWABLE_BOTTOM = "drawableBottom";            //$NON-NLS-1$
90     public static final String ATTR_DRAWABLE_TOP = "drawableTop";                  //$NON-NLS-1$
91 
92     // RelativeLayout layout params:
93     public static final String ATTR_LAYOUT_ALIGN_LEFT = "layout_alignLeft";        //$NON-NLS-1$
94     public static final String ATTR_LAYOUT_ALIGN_RIGHT = "layout_alignRight";      //$NON-NLS-1$
95     public static final String ATTR_LAYOUT_ALIGN_TOP = "layout_alignTop";          //$NON-NLS-1$
96     public static final String ATTR_LAYOUT_ALIGN_BOTTOM = "layout_alignBottom";    //$NON-NLS-1$
97     public static final String ATTR_LAYOUT_ALIGN_PARENT_TOP = "layout_alignParentTop"; //$NON-NLS-1$
98     public static final String ATTR_LAYOUT_ALIGN_PARENT_BOTTOM = "layout_alignParentBottom"; //$NON-NLS-1$
99     public static final String ATTR_LAYOUT_ALIGN_PARENT_LEFT = "layout_alignParentLeft";//$NON-NLS-1$
100     public static final String ATTR_LAYOUT_ALIGN_PARENT_RIGHT = "layout_alignParentRight";   //$NON-NLS-1$
101     public static final String ATTR_LAYOUT_ALIGN_WITH_PARENT_MISSING = "layout_alignWithParentIfMissing"; //$NON-NLS-1$
102     public static final String ATTR_LAYOUT_ALIGN_BASELINE = "layout_alignBaseline"; //$NON-NLS-1$
103     public static final String ATTR_LAYOUT_CENTER_IN_PARENT = "layout_centerInParent"; //$NON-NLS-1$
104     public static final String ATTR_LAYOUT_CENTER_VERTICAL = "layout_centerVertical"; //$NON-NLS-1$
105     public static final String ATTR_LAYOUT_CENTER_HORIZONTAL = "layout_centerHorizontal"; //$NON-NLS-1$
106     public static final String ATTR_LAYOUT_TO_RIGHT_OF = "layout_toRightOf";    //$NON-NLS-1$
107     public static final String ATTR_LAYOUT_TO_LEFT_OF = "layout_toLeftOf";      //$NON-NLS-1$
108     public static final String ATTR_LAYOUT_BELOW = "layout_below";              //$NON-NLS-1$
109     public static final String ATTR_LAYOUT_ABOVE = "layout_above";              //$NON-NLS-1$
110 
111     // GridLayout
112     public static final String ATTR_ROW_COUNT = "rowCount";                         //$NON-NLS-1$
113     public static final String ATTR_COLUMN_COUNT = "columnCount";                   //$NON-NLS-1$
114     public static final String ATTR_USE_DEFAULT_MARGINS = "useDefaultMargins";      //$NON-NLS-1$
115     public static final String ATTR_MARGINS_INCLUDED_IN_ALIGNMENT = "marginsIncludedInAlignment"; //$NON-NLS-1$
116 
117     // GridLayout layout params
118     public static final String ATTR_LAYOUT_ROW = "layout_row";                      //$NON-NLS-1$
119     public static final String ATTR_LAYOUT_ROW_SPAN = "layout_rowSpan";             //$NON-NLS-1$
120     public static final String ATTR_LAYOUT_COLUMN = "layout_column";                //$NON-NLS-1$
121     public static final String ATTR_LAYOUT_COLUMN_SPAN = "layout_columnSpan";       //$NON-NLS-1$
122 
123     public static final String ATTR_LAYOUT_Y = "layout_y";                      //$NON-NLS-1$
124     public static final String ATTR_LAYOUT_X = "layout_x";                      //$NON-NLS-1$
125     public static final String ATTR_NAME = "name";                              //$NON-NLS-1$
126 
127     public static final String VALUE_WRAP_CONTENT = "wrap_content";             //$NON-NLS-1$
128     public static final String VALUE_FILL_PARENT = "fill_parent";               //$NON-NLS-1$
129     public static final String VALUE_TRUE = "true";                             //$NON-NLS-1$
130     public static final String VALUE_FALSE= "false";                            //$NON-NLS-1$
131     public static final String VALUE_N_DP = "%ddp";                             //$NON-NLS-1$
132     public static final String VALUE_ZERO_DP = "0dp";                           //$NON-NLS-1$
133     public static final String VALUE_ONE_DP = "1dp";                            //$NON-NLS-1$
134     public static final String VALUE_TOP = "top";                               //$NON-NLS-1$
135     public static final String VALUE_LEFT = "left";                             //$NON-NLS-1$
136     public static final String VALUE_RIGHT = "right";                           //$NON-NLS-1$
137     public static final String VALUE_BOTTOM = "bottom";                         //$NON-NLS-1$
138     public static final String VALUE_CENTER_VERTICAL = "center_vertical";       //$NON-NLS-1$
139     public static final String VALUE_CENTER_HORIZONTAL = "center_horizontal";   //$NON-NLS-1$
140     public static final String VALUE_FILL_HORIZONTAL = "fill_horizontal";       //$NON-NLS-1$
141     public static final String VALUE_FILL_VERTICAL = "fill_vertical";           //$NON-NLS-1$
142     public static final String VALUE_0 = "0";                                   //$NON-NLS-1$
143     public static final String VALUE_1 = "1";                                   //$NON-NLS-1$
144 
145     // Gravity values. These have the GRAVITY_ prefix in front of value because we already
146     // have VALUE_CENTER_HORIZONTAL defined for layouts, and its definition conflicts
147     // (centerHorizontal versus center_horizontal)
148     public static final String GRAVITY_VALUE_ = "center";                             //$NON-NLS-1$
149     public static final String GRAVITY_VALUE_CENTER = "center";                       //$NON-NLS-1$
150     public static final String GRAVITY_VALUE_RIGHT = "right";                         //$NON-NLS-1$
151     public static final String GRAVITY_VALUE_LEFT = "left";                           //$NON-NLS-1$
152     public static final String GRAVITY_VALUE_BOTTOM = "bottom";                       //$NON-NLS-1$
153     public static final String GRAVITY_VALUE_TOP = "top";                             //$NON-NLS-1$
154     public static final String GRAVITY_VALUE_FILL_HORIZONTAL = "fill_horizontal";     //$NON-NLS-1$
155     public static final String GRAVITY_VALUE_FILL_VERTICAL = "fill_vertical";         //$NON-NLS-1$
156     public static final String GRAVITY_VALUE_CENTER_HORIZONTAL = "center_horizontal"; //$NON-NLS-1$
157     public static final String GRAVITY_VALUE_CENTER_VERTICAL = "center_vertical";     //$NON-NLS-1$
158     public static final String GRAVITY_VALUE_FILL = "fill";                           //$NON-NLS-1$
159 
160     /** The default prefix used for the {@link #ANDROID_URI} name space */
161     public static final String ANDROID_NS_NAME = "android"; //$NON-NLS-1$
162     /** The default prefix used for the {@link #ANDROID_URI} name space including the colon  */
163     public static final String ANDROID_NS_NAME_PREFIX = "android:"; //$NON-NLS-1$
164 
165     /**
166      * Namespace for the Android resource XML, i.e.
167      * "http://schemas.android.com/apk/res/android"
168      */
169     public static final String ANDROID_URI = SdkConstants.NS_RESOURCES;
170 
171     /**
172      * The top level android package as a prefix, "android.".
173      */
174     public static final String ANDROID_PKG_PREFIX = ANDROID_PKG + '.';
175 
176     /** The android.view. package prefix */
177     public static final String ANDROID_VIEW_PKG = ANDROID_PKG_PREFIX + "view."; //$NON-NLS-1$
178 
179     /** The android.widget. package prefix */
180     public static final String ANDROID_WIDGET_PREFIX = ANDROID_PKG_PREFIX + "widget."; //$NON-NLS-1$
181 
182     /** The android.webkit. package prefix */
183     public static final String ANDROID_WEBKIT_PKG = ANDROID_PKG_PREFIX + "webkit."; //$NON-NLS-1$
184 
185     /** The LayoutParams inner-class name suffix, .LayoutParams */
186     public static final String DOT_LAYOUT_PARAMS = ".LayoutParams"; //$NON-NLS-1$
187 
188     /** The fully qualified class name of an EditText view */
189     public static final String FQCN_EDIT_TEXT = "android.widget.EditText"; //$NON-NLS-1$
190 
191     /** The fully qualified class name of a LinearLayout view */
192     public static final String FQCN_LINEAR_LAYOUT = "android.widget.LinearLayout"; //$NON-NLS-1$
193 
194     /** The fully qualified class name of a RelativeLayout view */
195     public static final String FQCN_RELATIVE_LAYOUT = "android.widget.RelativeLayout"; //$NON-NLS-1$
196 
197     /** The fully qualified class name of a RelativeLayout view */
198     public static final String FQCN_GRID_LAYOUT = "android.widget.GridLayout"; //$NON-NLS-1$
199     public static final String FQCN_GRID_LAYOUT_V7 = "android.support.v7.widget.GridLayout"; //$NON-NLS-1$
200 
201     /** The fully qualified class name of a FrameLayout view */
202     public static final String FQCN_FRAME_LAYOUT = "android.widget.FrameLayout"; //$NON-NLS-1$
203 
204     /** The fully qualified class name of a TableRow view */
205     public static final String FQCN_TABLE_ROW = "android.widget.TableRow"; //$NON-NLS-1$
206 
207     /** The fully qualified class name of a TableLayout view */
208     public static final String FQCN_TABLE_LAYOUT = "android.widget.TableLayout"; //$NON-NLS-1$
209 
210     /** The fully qualified class name of a GridView view */
211     public static final String FQCN_GRID_VIEW = "android.widget.GridView"; //$NON-NLS-1$
212 
213     /** The fully qualified class name of a TabWidget view */
214     public static final String FQCN_TAB_WIDGET = "android.widget.TabWidget"; //$NON-NLS-1$
215 
216     /** The fully qualified class name of a Button view */
217     public static final String FQCN_BUTTON = "android.widget.Button"; //$NON-NLS-1$
218 
219     /** The fully qualified class name of a RadioButton view */
220     public static final String FQCN_RADIO_BUTTON = "android.widget.RadioButton"; //$NON-NLS-1$
221 
222     /** The fully qualified class name of a ToggleButton view */
223     public static final String FQCN_TOGGLE_BUTTON = "android.widget.ToggleButton"; //$NON-NLS-1$
224 
225     /** The fully qualified class name of a Spinner view */
226     public static final String FQCN_SPINNER = "android.widget.Spinner"; //$NON-NLS-1$
227 
228     /** The fully qualified class name of an AdapterView */
229     public static final String FQCN_ADAPTER_VIEW = "android.widget.AdapterView"; //$NON-NLS-1$
230 
231     /** The fully qualified class name of a ListView */
232     public static final String FQCN_LIST_VIEW = "android.widget.ListView"; //$NON-NLS-1$
233 
234     /** The fully qualified class name of an ExpandableListView */
235     public static final String FQCN_EXPANDABLE_LIST_VIEW = "android.widget.ExpandableListView"; //$NON-NLS-1$
236 
237     /** The fully qualified class name of a GestureOverlayView */
238     public static final String FQCN_GESTURE_OVERLAY_VIEW = "android.gesture.GestureOverlayView"; //$NON-NLS-1$
239 
240     /** The fully qualified class name of a DatePicker */
241     public static final String FQCN_DATE_PICKER = "android.widget.DatePicker"; //$NON-NLS-1$
242 
243     /** The fully qualified class name of a TimePicker */
244     public static final String FQCN_TIME_PICKER = "android.widget.TimePicker"; //$NON-NLS-1$
245 
246     /** The fully qualified class name of a RadioGroup */
247     public static final String FQCN_RADIO_GROUP = "android.widgets.RadioGroup";  //$NON-NLS-1$
248 
249     /** The fully qualified class name of a Space */
250     public static final String FQCN_SPACE = "android.widget.Space"; //$NON-NLS-1$
251     public static final String FQCN_SPACE_V7 = "android.support.v7.widget.Space"; //$NON-NLS-1$
252 
253     /** The fully qualified class name of a TextView view */
254     public static final String FQCN_TEXT_VIEW = "android.widget.TextView"; //$NON-NLS-1$
255 
256     /** The fully qualified class name of an ImageView view */
257     public static final String FQCN_IMAGE_VIEW = "android.widget.ImageView"; //$NON-NLS-1$
258 
259     public static final String ATTR_SRC = "src"; //$NON-NLS-1$
260 
261     // like fill_parent for API 8
262     public static final String VALUE_MATCH_PARENT = "match_parent"; //$NON-NLS-1$
263 
264     public static final String ATTR_GRAVITY = "gravity"; //$NON-NLS-1$
265     public static final String ATTR_WEIGHT_SUM = "weightSum"; //$NON-NLS-1$
266     public static final String ATTR_BASELINE_ALIGNED = "baselineAligned"; //$NON-NLS-1$
267     public static String ATTR_ORIENTATION = "orientation"; //$NON-NLS-1$
268     public static String ATTR_EMS = "ems"; //$NON-NLS-1$
269 
270     public static String VALUE_HORIZONTAL = "horizontal"; //$NON-NLS-1$
271 
272     public static String VALUE_VERTICAL = "vertical"; //$NON-NLS-1$
273 
274     /** The prefix for new id attribute values, @+id/ */
275     public static String NEW_ID_PREFIX = "@+id/"; //$NON-NLS-1$
276 
277     /** The prefix for existing id attribute values, @id/ */
278     public static String ID_PREFIX = "@id/"; //$NON-NLS-1$
279 
280     /** Prefix for resources that reference layouts */
281     public static String LAYOUT_PREFIX = "@layout/"; //$NON-NLS-1$
282 
283     /** Prefix for resources that reference drawables */
284     public static String DRAWABLE_PREFIX = "@drawable/"; //$NON-NLS-1$
285 
286     /** Prefix for resources that reference strings */
287     public static String STRING_PREFIX = "@string/"; //$NON-NLS-1$
288 
289     /** Prefix for resources that reference Android strings */
290     public static String ANDROID_STRING_PREFIX = "@android:string/"; //$NON-NLS-1$
291 
292     /** Prefix for resources that reference Android layouts */
293     public static String ANDROID_LAYOUT_PREFIX = "@android:layout/"; //$NON-NLS-1$
294 }
295