public class ViewPosition
extends java.lang.Object
view rectangle, viewport rectangle (view rectangle minus
padding), visible rectangle (part of viewport which is visible on screen)
and image rectangle (position of the underlying image taking into account
ImageView.getScaleType(), or same as viewport if view is not an
ImageView or if ImageView.getDrawable() is null).
All positions are in screen coordinates.
To create instance of this class use from(View) static method. But note, that view
should already be laid out and have correct View.getWidth() and View.getHeight()
values.
You can also serialize and deserialize this class to string using pack() and
unpack(String) methods. This can be useful to pass view position between activities.| Modifier and Type | Field and Description |
|---|---|
android.graphics.Rect |
image |
android.graphics.Rect |
view |
android.graphics.Rect |
viewport |
android.graphics.Rect |
visible |
| Modifier and Type | Method and Description |
|---|---|
static void |
apply(ViewPosition pos,
android.graphics.Point point)
Computes minimal view position for given point.
|
static boolean |
apply(ViewPosition pos,
android.view.View view)
Computes view position and stores it in given
pos. |
static ViewPosition |
from(android.view.View view)
Computes and returns view position.
|
static ViewPosition |
newInstance() |
java.lang.String |
pack()
Packs this ViewPosition into string, which can be passed i.e.
|
void |
set(ViewPosition pos) |
static ViewPosition |
unpack(java.lang.String str)
Restores ViewPosition from the string created by
pack() method. |
public final android.graphics.Rect view
public final android.graphics.Rect viewport
public final android.graphics.Rect visible
public final android.graphics.Rect image
public void set(ViewPosition pos)
public static ViewPosition newInstance()
public static ViewPosition from(android.view.View view)
public static boolean apply(ViewPosition pos, android.view.View view)
pos. Note, that view should be already
attached and laid out before calling this method.public static void apply(ViewPosition pos, android.graphics.Point point)
public java.lang.String pack()
unpack(String)public static ViewPosition unpack(java.lang.String str)
pack() method.