|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.support.v4.view.ViewCompat
public class ViewCompat
Helper for accessing features in View
introduced after API
level 4 in a backwards compatible fashion.
Field Summary | |
---|---|
static int |
IMPORTANT_FOR_ACCESSIBILITY_AUTO
Automatically determine whether a view is important for accessibility. |
static int |
IMPORTANT_FOR_ACCESSIBILITY_NO
The view is not important for accessibility. |
static int |
IMPORTANT_FOR_ACCESSIBILITY_YES
The view is important for accessibility. |
static int |
OVER_SCROLL_ALWAYS
Always allow a user to over-scroll this view, provided it is a view that can scroll. |
static int |
OVER_SCROLL_IF_CONTENT_SCROLLS
Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. |
static int |
OVER_SCROLL_NEVER
Never allow a user to over-scroll this view. |
Constructor Summary | |
---|---|
ViewCompat()
|
Method Summary | |
---|---|
static boolean |
canScrollHorizontally(View v,
int direction)
Check if this view can be scrolled horizontally in a certain direction. |
static boolean |
canScrollVertically(View v,
int direction)
Check if this view can be scrolled vertically in a certain direction. |
static AccessibilityNodeProviderCompat |
getAccessibilityNodeProvider(View view)
Gets the provider for managing a virtual view hierarchy rooted at this View and reported to android.accessibilityservice.AccessibilityService s
that explore the window content. |
static int |
getImportantForAccessibility(View view)
Gets the mode for determining whether this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. |
static int |
getOverScrollMode(View v)
Returns the over-scroll mode for this view. |
static boolean |
hasTransientState(View view)
Indicates whether the view is currently tracking transient state that the app should not need to concern itself with saving and restoring, but that the framework should take special note to preserve when possible. |
static void |
onInitializeAccessibilityEvent(View v,
AccessibilityEvent event)
Initializes an AccessibilityEvent with information about
this View which is the event source. |
static void |
onInitializeAccessibilityNodeInfo(View v,
AccessibilityNodeInfoCompat info)
Initializes an android.view.accessibility.AccessibilityNodeInfo with information
about this view. |
static void |
onPopulateAccessibilityEvent(View v,
AccessibilityEvent event)
Called from View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
giving a chance to this View to populate the accessibility event with its
text content. |
static void |
postInvalidateOnAnimation(View view)
Cause an invalidate to happen on the next animation time step, typically the next display frame. |
static void |
postInvalidateOnAnimation(View view,
int left,
int top,
int right,
int bottom)
Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame. |
static void |
postOnAnimation(View view,
java.lang.Runnable action)
Causes the Runnable to execute on the next animation time step. |
static void |
postOnAnimationDelayed(View view,
java.lang.Runnable action,
long delayMillis)
Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. |
static void |
setAccessibilityDelegate(View v,
AccessibilityDelegateCompat delegate)
Sets a delegate for implementing accessibility support via compositon as opposed to inheritance. |
static void |
setHasTransientState(View view,
boolean hasTransientState)
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible. |
static void |
setImportantForAccessibility(View view,
int mode)
Sets how to determine whether this view is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. |
static void |
setOverScrollMode(View v,
int overScrollMode)
Set the over-scroll mode for this view. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int OVER_SCROLL_ALWAYS
public static final int OVER_SCROLL_IF_CONTENT_SCROLLS
public static final int OVER_SCROLL_NEVER
public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO
public static final int IMPORTANT_FOR_ACCESSIBILITY_YES
public static final int IMPORTANT_FOR_ACCESSIBILITY_NO
Constructor Detail |
---|
public ViewCompat()
Method Detail |
---|
public static boolean canScrollHorizontally(View v, int direction)
v
- The View against which to invoke the method.direction
- Negative to check scrolling left, positive to check scrolling right.
public static boolean canScrollVertically(View v, int direction)
v
- The View against which to invoke the method.direction
- Negative to check scrolling up, positive to check scrolling down.
public static int getOverScrollMode(View v)
OVER_SCROLL_ALWAYS
(default), OVER_SCROLL_IF_CONTENT_SCROLLS
(allow over-scrolling only if the view content is larger than the container),
or OVER_SCROLL_NEVER
.
v
- The View against which to invoke the method.
public static void setOverScrollMode(View v, int overScrollMode)
OVER_SCROLL_ALWAYS
(default), OVER_SCROLL_IF_CONTENT_SCROLLS
(allow over-scrolling only if the view content is larger than the container),
or OVER_SCROLL_NEVER
.
Setting the over-scroll mode of a view will have an effect only if the
view is capable of scrolling.
v
- The View against which to invoke the method.overScrollMode
- The new over-scroll mode for this view.public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event)
View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
giving a chance to this View to populate the accessibility event with its
text content. While this method is free to modify event
attributes other than text content, doing so should normally be performed in
View#onInitializeAccessibilityEvent(AccessibilityEvent)
.
Example: Adding formatted date string to an accessibility event in addition to the text added by the super implementation:
public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY; String selectedDateUtterance = DateUtils.formatDateTime(mContext, mCurrentDate.getTimeInMillis(), flags); event.getText().add(selectedDateUtterance); }
If an android.view.View.AccessibilityDelegate
has been specified via calling
View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)
its
android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
AccessibilityEvent)
is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
v
- The View against which to invoke the method.event
- The accessibility event which to populate.View#sendAccessibilityEvent(int)
,
View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event)
AccessibilityEvent
with information about
this View which is the event source. In other words, the source of
an accessibility event is the view whose state change triggered firing
the event.
Example: Setting the password property of an event in addition to properties set by the super implementation:
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setPassword(true); }
If an android.view.View.AccessibilityDelegate
has been specified via calling
View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)
its
android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
AccessibilityEvent)
is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
v
- The View against which to invoke the method.event
- The event to initialize.View#sendAccessibilityEvent(int)
,
View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info)
android.view.accessibility.AccessibilityNodeInfo
with information
about this view. The base implementation sets:
android.view.accessibility.AccessibilityNodeInfo#setParent(View)
,android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)
,android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)
,android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)
,android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)
,android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)
,android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)
,android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)
,android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)
,android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)
,android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)
,android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)
,Subclasses should override this method, call the super implementation, and set additional attributes.
If an android.view.View.AccessibilityDelegate
has been specified via calling
View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)
its
android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
android.view.accessibility.AccessibilityNodeInfo)
is responsible for handling this call.
v
- The View against which to invoke the method.info
- The instance to initialize.public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate)
android.view.View.AccessibilityDelegate
.
v
- The View against which to invoke the method.delegate
- The delegate instance.android.view.View.AccessibilityDelegate
public static boolean hasTransientState(View view)
view
- View to check for transient state
public static void setHasTransientState(View view, boolean hasTransientState)
view
- View tracking transient statehasTransientState
- true if this view has transient statepublic static void postInvalidateOnAnimation(View view)
Cause an invalidate to happen on the next animation time step, typically the next display frame.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
view
- View to invalidatepublic static void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom)
Cause an invalidate of the specified area to happen on the next animation time step, typically the next display frame.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
view
- View to invalidateleft
- The left coordinate of the rectangle to invalidate.top
- The top coordinate of the rectangle to invalidate.right
- The right coordinate of the rectangle to invalidate.bottom
- The bottom coordinate of the rectangle to invalidate.public static void postOnAnimation(View view, java.lang.Runnable action)
Causes the Runnable to execute on the next animation time step. The runnable will be run on the user interface thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
view
- View to post this Runnable toaction
- The Runnable that will be executed.public static void postOnAnimationDelayed(View view, java.lang.Runnable action, long delayMillis)
Causes the Runnable to execute on the next animation time step, after the specified amount of time elapses. The runnable will be run on the user interface thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
view
- The view to post this Runnable toaction
- The Runnable that will be executed.delayMillis
- The delay (in milliseconds) until the Runnable
will be executed.public static int getImportantForAccessibility(View view)
view
- The view whose property to get.
IMPORTANT_FOR_ACCESSIBILITY_YES
,
IMPORTANT_FOR_ACCESSIBILITY_NO
,
IMPORTANT_FOR_ACCESSIBILITY_AUTO
public static void setImportantForAccessibility(View view, int mode)
view
- The view whose property to set.mode
- How to determine whether this view is important for accessibility.IMPORTANT_FOR_ACCESSIBILITY_YES
,
IMPORTANT_FOR_ACCESSIBILITY_NO
,
IMPORTANT_FOR_ACCESSIBILITY_AUTO
public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view)
android.accessibilityservice.AccessibilityService
s
that explore the window content.
If this method returns an instance, this instance is responsible for managing
AccessibilityNodeInfoCompat
s describing the virtual sub-tree rooted at
this View including the one representing the View itself. Similarly the returned
instance is responsible for performing accessibility actions on any virtual
view or the root view itself.
If an AccessibilityDelegateCompat
has been specified via calling
#setAccessibilityDelegate(View, AccessibilityDelegateCompat) its
{@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
is responsible for handling this call.
view
- The view whose property to get.
AccessibilityNodeProviderCompat
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |