@@ -153,7 +153,8 @@ public static void apply(int gravity, int w, int h, Rect container, Rect outRect
153153 * container.
154154 * @param layoutDirection The layout direction.
155155 *
156- * @hide
156+ * @see {@link View#LAYOUT_DIRECTION_LTR}
157+ * @see {@link View#LAYOUT_DIRECTION_RTL}
157158 */
158159 public static void apply (int gravity , int w , int h , Rect container ,
159160 Rect outRect , int layoutDirection ) {
@@ -267,6 +268,37 @@ public static void apply(int gravity, int w, int h, Rect container,
267268 }
268269 }
269270
271+ /**
272+ * Apply a gravity constant to an object.
273+ *
274+ * @param gravity The desired placement of the object, as defined by the
275+ * constants in this class.
276+ * @param w The horizontal size of the object.
277+ * @param h The vertical size of the object.
278+ * @param container The frame of the containing space, in which the object
279+ * will be placed. Should be large enough to contain the
280+ * width and height of the object.
281+ * @param xAdj Offset to apply to the X axis. If gravity is LEFT this
282+ * pushes it to the right; if gravity is RIGHT it pushes it to
283+ * the left; if gravity is CENTER_HORIZONTAL it pushes it to the
284+ * right or left; otherwise it is ignored.
285+ * @param yAdj Offset to apply to the Y axis. If gravity is TOP this pushes
286+ * it down; if gravity is BOTTOM it pushes it up; if gravity is
287+ * CENTER_VERTICAL it pushes it down or up; otherwise it is
288+ * ignored.
289+ * @param outRect Receives the computed frame of the object in its
290+ * container.
291+ * @param layoutDirection The layout direction.
292+ *
293+ * @see {@link View#LAYOUT_DIRECTION_LTR}
294+ * @see {@link View#LAYOUT_DIRECTION_RTL}
295+ */
296+ public static void apply (int gravity , int w , int h , Rect container ,
297+ int xAdj , int yAdj , Rect outRect , int layoutDirection ) {
298+ int absGravity = getAbsoluteGravity (gravity , layoutDirection );
299+ apply (absGravity , w , h , container , xAdj , yAdj , outRect );
300+ }
301+
270302 /**
271303 * Apply additional gravity behavior based on the overall "display" that an
272304 * object exists in. This can be used after
@@ -320,7 +352,32 @@ public static void applyDisplay(int gravity, Rect display, Rect inoutObj) {
320352 }
321353 }
322354 }
323-
355+
356+ /**
357+ * Apply additional gravity behavior based on the overall "display" that an
358+ * object exists in. This can be used after
359+ * {@link #apply(int, int, int, Rect, int, int, Rect)} to place the object
360+ * within a visible display. By default this moves or clips the object
361+ * to be visible in the display; the gravity flags
362+ * {@link #DISPLAY_CLIP_HORIZONTAL} and {@link #DISPLAY_CLIP_VERTICAL}
363+ * can be used to change this behavior.
364+ *
365+ * @param gravity Gravity constants to modify the placement within the
366+ * display.
367+ * @param display The rectangle of the display in which the object is
368+ * being placed.
369+ * @param inoutObj Supplies the current object position; returns with it
370+ * modified if needed to fit in the display.
371+ * @param layoutDirection The layout direction.
372+ *
373+ * @see {@link View#LAYOUT_DIRECTION_LTR}
374+ * @see {@link View#LAYOUT_DIRECTION_RTL}
375+ */
376+ public static void applyDisplay (int gravity , Rect display , Rect inoutObj , int layoutDirection ) {
377+ int absGravity = getAbsoluteGravity (gravity , layoutDirection );
378+ applyDisplay (absGravity , display , inoutObj );
379+ }
380+
324381 /**
325382 * <p>Indicate whether the supplied gravity has a vertical pull.</p>
326383 *
0 commit comments