简介
直接继承Button
- 支持textAllCaps回溯到的风格属性 Eclair MR1。
- 通过背景色调方法允许动态色调背景 ViewCompat。
- 允许使用backgroundTint和 设置背景色调backgroundTintMode。
使用
相对Button而言增加了水波纹特效
使用 android:textAllCaps 这个属性可以使英文自动转换大写
公共方法
onInitializeAccessibilityEvent (AccessibilityEvent event)
初始化AccessibilityEvent有关此视图的信息,该事件源是事件源。换句话说,可访问性事件的来源是其状态改变触发触发事件的视图。
示例:设置事件的密码属性以及超级实现设置的属性:
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
event.setPassword(true);
}
onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)
使用关于此视图的信息初始化一个可访问性节点信息。基本实现集:
- setParent(View)
- setBoundsInParent(Rect)
- setBoundsInScreen(Rect)
- setPackageName(CharSequence)
- setClassName(CharSequence)
- setContentDescription(CharSequence)
- setEnabled(boolean)
- setClickable(boolean)
- setFocusable(boolean)
- setFocused(boolean)
- setLongClickable(boolean)
- setSelected(boolean)
- setContextClickable(boolean)
子类应该覆盖这个方法,调用super实现,并设置额外的属性。
AccessibilityNodeInfo
此类表示窗口内容的节点以及可从其源请求的操作。从AccessibilityService窗口的角度来看, 内容被呈现为可访问性节点信息的树,其可以或可以不将一对一映射到视图层次结构。换句话说,自定义视图可以自动报告为可访问性节点信息的树。
以下摘自
http://android.xsoftlab.net/reference/android/view/accessibility/AccessibilityNodeInfo.html
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ACTION_ACCESSIBILITY_FOCUS | Action that gives accessibility focus to the node. | |||||||||
String | ACTION_ARGUMENT_COLUMN_INT | Argument for specifying the collection column to make visible on screen. | |||||||||
String | ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN | Argument for whether when moving at granularity to extend the selection or to move it otherwise. | |||||||||
String | ACTION_ARGUMENT_HTML_ELEMENT_STRING | Argument for which HTML element to get moving to the next/previous HTML element. | |||||||||
String | ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT | Argument for which movement granularity to be used when traversing the node text. | |||||||||
String | ACTION_ARGUMENT_ROW_INT | Argument for specifying the collection row to make visible on screen. | |||||||||
String | ACTION_ARGUMENT_SELECTION_END_INT | Argument for specifying the selection end. | |||||||||
String | ACTION_ARGUMENT_SELECTION_START_INT | Argument for specifying the selection start. | |||||||||
String | ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE | Argument for specifying the text content to set. | |||||||||
int | ACTION_CLEAR_ACCESSIBILITY_FOCUS | Action that clears accessibility focus of the node. | |||||||||
int | ACTION_CLEAR_FOCUS | Action that clears input focus of the node. | |||||||||
int | ACTION_CLEAR_SELECTION | Action that deselects the node. | |||||||||
int | ACTION_CLICK | Action that clicks on the node info. | |||||||||
int | ACTION_COLLAPSE | Action to collapse an expandable node. | |||||||||
int | ACTION_COPY | Action to copy the current selection to the clipboard. | |||||||||
int | ACTION_CUT | Action to cut the current selection and place it to the clipboard. | |||||||||
int | ACTION_DISMISS | Action to dismiss a dismissable node. | |||||||||
int | ACTION_EXPAND | Action to expand an expandable node. | |||||||||
int | ACTION_FOCUS | Action that gives input focus to the node. | |||||||||
int | ACTION_LONG_CLICK | Action that long clicks on the node. | |||||||||
int | ACTION_NEXT_AT_MOVEMENT_GRANULARITY | Action that requests to go to the next entity in this node’s text at a given movement granularity. | |||||||||
int | ACTION_NEXT_HTML_ELEMENT | Action to move to the next HTML element of a given type. | |||||||||
int | ACTION_PASTE | Action to paste the current clipboard content. | |||||||||
int | ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY | Action that requests to go to the previous entity in this node’s text at a given movement granularity. | |||||||||
int | ACTION_PREVIOUS_HTML_ELEMENT | Action to move to the previous HTML element of a given type. | |||||||||
int | ACTION_SCROLL_BACKWARD | Action to scroll the node content backward. | |||||||||
int | ACTION_SCROLL_FORWARD | Action to scroll the node content forward. | |||||||||
int | ACTION_SELECT | Action that selects the node. | |||||||||
int | ACTION_SET_SELECTION | Action to set the selection. | |||||||||
int | ACTION_SET_TEXT | Action that sets the text of the node. | |||||||||
int | FOCUS_ACCESSIBILITY | The accessibility focus. | |||||||||
int | FOCUS_INPUT | The input focus. | |||||||||
int | MOVEMENT_GRANULARITY_CHARACTER | Movement granularity bit for traversing the text of a node by character. | |||||||||
int | MOVEMENT_GRANULARITY_LINE | Movement granularity bit for traversing the text of a node by line. | |||||||||
int | MOVEMENT_GRANULARITY_PAGE | Movement granularity bit for traversing the text of a node by page. | |||||||||
int | MOVEMENT_GRANULARITY_PARAGRAPH | Movement granularity bit for traversing the text of a node by paragraph. | |||||||||
int | MOVEMENT_GRANULARITY_WORD | Movement granularity bit for traversing the text of a node by word. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void | addAction(AccessibilityNodeInfo.AccessibilityAction action)
Adds an action that can be performed on the node.
| ||||||||||
void | addAction(int action)
This method was deprecated in API level 21. This has been deprecated for addAction(AccessibilityAction)
| ||||||||||
void | addChild(View child)
Adds a child.
| ||||||||||
void | addChild(View root, int virtualDescendantId)
Adds a virtual child which is a descendant of the given
root .
| ||||||||||
boolean | canOpenPopup()
Gets if this node opens a popup or a dialog.
| ||||||||||
int | describeContents()
Describe the kinds of special objects contained in this Parcelable’s marshalled representation.
| ||||||||||
boolean | equals(Object object)
Compares this instance with the specified object and indicates if they are equal.
| ||||||||||
List<AccessibilityNodeInfo> | findAccessibilityNodeInfosByText(String text)
Finds
AccessibilityNodeInfo s by text.
| ||||||||||
List<AccessibilityNodeInfo> | findAccessibilityNodeInfosByViewId(String viewId)
Finds
AccessibilityNodeInfo s by the fully qualified view id’s resource name where a fully qualified id is of the from “package:id/id_resource_name”.
| ||||||||||
AccessibilityNodeInfo | findFocus(int focus)
Find the view that has the specified focus type.
| ||||||||||
AccessibilityNodeInfo | focusSearch(int direction)
Searches for the nearest view in the specified direction that can take the input focus.
| ||||||||||
List<AccessibilityNodeInfo.AccessibilityAction> | getActionList()
Gets the actions that can be performed on the node.
| ||||||||||
int | getActions()
This method was deprecated in API level 21. Use getActionList() .
| ||||||||||
void | getBoundsInParent(Rect outBounds)
Gets the node bounds in parent coordinates.
| ||||||||||
void | getBoundsInScreen(Rect outBounds)
Gets the node bounds in screen coordinates.
| ||||||||||
AccessibilityNodeInfo | getChild(int index)
Get the child at given index.
| ||||||||||
int | getChildCount()
Gets the number of children.
| ||||||||||
CharSequence | getClassName()
Gets the class this node comes from.
| ||||||||||
AccessibilityNodeInfo.CollectionInfo | getCollectionInfo()
Gets the collection info if the node is a collection.
| ||||||||||
AccessibilityNodeInfo.CollectionItemInfo | getCollectionItemInfo()
Gets the collection item info if the node is a collection item.
| ||||||||||
CharSequence | getContentDescription()
Gets the content description of this node.
| ||||||||||
CharSequence | getError()
Gets the error text of this node.
| ||||||||||
Bundle | getExtras()
Gets an optional bundle with extra data.
| ||||||||||
int | getInputType()
Gets the input type of the source as defined by
InputType .
| ||||||||||
AccessibilityNodeInfo | getLabelFor()
Gets the node info for which the view represented by this info serves as a label for accessibility purposes.
| ||||||||||
AccessibilityNodeInfo | getLabeledBy()
Gets the node info which serves as the label of the view represented by this info for accessibility purposes.
| ||||||||||
int | getLiveRegion()
Gets the node’s live region mode.
| ||||||||||
int | getMaxTextLength()
Returns the maximum text length for this node.
| ||||||||||
int | getMovementGranularities()
Gets the movement granularities for traversing the text of this node.
| ||||||||||
CharSequence | getPackageName()
Gets the package this node comes from.
| ||||||||||
AccessibilityNodeInfo | getParent()
Gets the parent.
| ||||||||||
AccessibilityNodeInfo.RangeInfo | getRangeInfo()
Gets the range info if this node is a range.
| ||||||||||
CharSequence | getText()
Gets the text of this node.
| ||||||||||
int | getTextSelectionEnd()
Gets the text selection end.
| ||||||||||
int | getTextSelectionStart()
Gets the text selection start.
| ||||||||||
AccessibilityNodeInfo | getTraversalAfter()
Gets the node after which this one is visited in accessibility traversal.
| ||||||||||
AccessibilityNodeInfo | getTraversalBefore()
Gets the node before which this one is visited during traversal.
| ||||||||||
String | getViewIdResourceName()
Gets the fully qualified resource name of the source view’s id.
| ||||||||||
AccessibilityWindowInfo | getWindow()
Gets the window to which this node belongs.
| ||||||||||
int | getWindowId()
Gets the id of the window from which the info comes from.
| ||||||||||
int | hashCode()
Returns an integer hash code for this object.
| ||||||||||
boolean | isAccessibilityFocused()
Gets whether this node is accessibility focused.
| ||||||||||
boolean | isCheckable()
Gets whether this node is checkable.
| ||||||||||
boolean | isChecked()
Gets whether this node is checked.
| ||||||||||
boolean | isClickable()
Gets whether this node is clickable.
| ||||||||||
boolean | isContentInvalid()
Gets if the content of this node is invalid.
| ||||||||||
boolean | isContextClickable()
Gets whether this node is context clickable.
| ||||||||||
boolean | isDismissable()
Gets if the node can be dismissed.
| ||||||||||
boolean | isEditable()
Gets if the node is editable.
| ||||||||||
boolean | isEnabled()
Gets whether this node is enabled.
| ||||||||||
boolean | isFocusable()
Gets whether this node is focusable.
| ||||||||||
boolean | isFocused()
Gets whether this node is focused.
| ||||||||||
boolean | isLongClickable()
Gets whether this node is long clickable.
| ||||||||||
boolean | isMultiLine()
Gets if the node is a multi line editable text.
| ||||||||||
boolean | isPassword()
Gets whether this node is a password.
| ||||||||||
boolean | isScrollable()
Gets if the node is scrollable.
| ||||||||||
boolean | isSelected()
Gets whether this node is selected.
| ||||||||||
boolean | isVisibleToUser()
Gets whether this node is visible to the user.
| ||||||||||
static AccessibilityNodeInfo | obtain(View root, int virtualDescendantId)
Returns a cached instance if such is available otherwise a new one and sets the source.
| ||||||||||
static AccessibilityNodeInfo | obtain()
Returns a cached instance if such is available otherwise a new one.
| ||||||||||
static AccessibilityNodeInfo | obtain(View source)
Returns a cached instance if such is available otherwise a new one and sets the source.
| ||||||||||
static AccessibilityNodeInfo | obtain(AccessibilityNodeInfo info)
Returns a cached instance if such is available or a new one is create.
| ||||||||||
boolean | performAction(int action)
Performs an action on the node.
| ||||||||||
boolean | performAction(int action, Bundle arguments)
Performs an action on the node.
| ||||||||||
void | recycle()
Return an instance back to be reused.
| ||||||||||
boolean | refresh()
Refreshes this info with the latest state of the view it represents.
| ||||||||||
void | removeAction(int action)
This method was deprecated in API level 21. Use removeAction(AccessibilityAction)
| ||||||||||
boolean | removeAction(AccessibilityNodeInfo.AccessibilityAction action)
Removes an action that can be performed on the node.
| ||||||||||
boolean | removeChild(View root, int virtualDescendantId)
Removes a virtual child which is a descendant of the given
root .
| ||||||||||
boolean | removeChild(View child)
Removes a child.
| ||||||||||
void | setAccessibilityFocused(boolean focused)
Sets whether this node is accessibility focused.
| ||||||||||
void | setBoundsInParent(Rect bounds)
Sets the node bounds in parent coordinates.
| ||||||||||
void | setBoundsInScreen(Rect bounds)
Sets the node bounds in screen coordinates.
| ||||||||||
void | setCanOpenPopup(boolean opensPopup)
Sets if this node opens a popup or a dialog.
| ||||||||||
void | setCheckable(boolean checkable)
Sets whether this node is checkable.
| ||||||||||
void | setChecked(boolean checked)
Sets whether this node is checked.
| ||||||||||
void | setClassName(CharSequence className)
Sets the class this node comes from.
| ||||||||||
void | setClickable(boolean clickable)
Sets whether this node is clickable.
| ||||||||||
void | setCollectionInfo(AccessibilityNodeInfo.CollectionInfo collectionInfo)
Sets the collection info if the node is a collection.
| ||||||||||
void | setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo collectionItemInfo)
Sets the collection item info if the node is a collection item.
| ||||||||||
void | setContentDescription(CharSequence contentDescription)
Sets the content description of this node.
| ||||||||||
void | setContentInvalid(boolean contentInvalid)
Sets if the content of this node is invalid.
| ||||||||||
void | setContextClickable(boolean contextClickable)
Sets whether this node is context clickable.
| ||||||||||
void | setDismissable(boolean dismissable)
Sets if the node can be dismissed.
| ||||||||||
void | setEditable(boolean editable)
Sets whether this node is editable.
| ||||||||||
void | setEnabled(boolean enabled)
Sets whether this node is enabled.
| ||||||||||
void | setError(CharSequence error)
Sets the error text of this node.
| ||||||||||
void | setFocusable(boolean focusable)
Sets whether this node is focusable.
| ||||||||||
void | setFocused(boolean focused)
Sets whether this node is focused.
| ||||||||||
void | setInputType(int inputType)
Sets the input type of the source as defined by
InputType .
| ||||||||||
void | setLabelFor(View labeled)
Sets the view for which the view represented by this info serves as a label for accessibility purposes.
| ||||||||||
void | setLabelFor(View root, int virtualDescendantId)
Sets the view for which the view represented by this info serves as a label for accessibility purposes.
| ||||||||||
void | setLabeledBy(View label)
Sets the view which serves as the label of the view represented by this info for accessibility purposes.
| ||||||||||
void | setLabeledBy(View root, int virtualDescendantId)
Sets the view which serves as the label of the view represented by this info for accessibility purposes.
| ||||||||||
void | setLiveRegion(int mode)
Sets the node’s live region mode.
| ||||||||||
void | setLongClickable(boolean longClickable)
Sets whether this node is long clickable.
| ||||||||||
void | setMaxTextLength(int max)
Sets the maximum text length, or -1 for no limit.
| ||||||||||
void | setMovementGranularities(int granularities)
Sets the movement granularities for traversing the text of this node.
| ||||||||||
void | setMultiLine(boolean multiLine)
Sets if the node is a multi line editable text.
| ||||||||||
void | setPackageName(CharSequence packageName)
Sets the package this node comes from.
| ||||||||||
void | setParent(View parent)
Sets the parent.
| ||||||||||
void | setParent(View root, int virtualDescendantId)
Sets the parent to be a virtual descendant of the given
root .
| ||||||||||
void | setPassword(boolean password)
Sets whether this node is a password.
| ||||||||||
void | setRangeInfo(AccessibilityNodeInfo.RangeInfo rangeInfo)
Sets the range info if this node is a range.
| ||||||||||
void | setScrollable(boolean scrollable)
Sets if the node is scrollable.
| ||||||||||
void | setSelected(boolean selected)
Sets whether this node is selected.
| ||||||||||
void | setSource(View source)
Sets the source.
| ||||||||||
void | setSource(View root, int virtualDescendantId)
Sets the source to be a virtual descendant of the given
root .
| ||||||||||
void | setText(CharSequence text)
Sets the text of this node.
| ||||||||||
void | setTextSelection(int start, int end)
Sets the text selection start and end.
| ||||||||||
void | setTraversalAfter(View view)
Sets the view whose node is visited after this one in accessibility traversal.
| ||||||||||
void | setTraversalAfter(View root, int virtualDescendantId)
Sets the node after which this one is visited in accessibility traversal.
| ||||||||||
void | setTraversalBefore(View view)
Sets the view before whose node this one should be visited during traversal.
| ||||||||||
void | setTraversalBefore(View root, int virtualDescendantId)
Sets the node before which this one is visited during traversal.
| ||||||||||
void | setViewIdResourceName(String viewIdResName)
Sets the fully qualified resource name of the source view’s id.
| ||||||||||
void | setVisibleToUser(boolean visibleToUser)
Sets whether this node is visible to the user.
| ||||||||||
String | toString()
Returns a string containing a concise, human-readable description of this object.
| ||||||||||
void | writeToParcel(Parcel parcel, int flags)
Flatten this object in to a Parcel.
Note: After the instance is written to a parcel it is recycled. |