Android widget之AppCompatButton
来源:互联网 发布:js cookie删除 编辑:程序博客网 时间:2024/05/19 08:25
简介
直接继承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
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
void addChild(View child) addAction(AccessibilityAction)
Adds a child.
void addChild(View root, int virtualDescendantId) Adds a virtual child which is a descendant of the given
boolean canOpenPopup() root
. 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
List<AccessibilityNodeInfo> findAccessibilityNodeInfosByViewId(String viewId) AccessibilityNodeInfo
s by text. Finds
AccessibilityNodeInfo findFocus(int focus) 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”. 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
void getBoundsInParent(Rect outBounds) getActionList()
. 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
AccessibilityNodeInfo getLabelFor() InputType
. 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
boolean removeAction(AccessibilityNodeInfo.AccessibilityAction action) removeAction(AccessibilityAction)
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
boolean removeChild(View child) root
. 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
void setLabelFor(View labeled) InputType
. 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
void setPassword(boolean password) root
. 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
void setText(CharSequence text) root
. 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.
知识贵在分享!
阅读全文
0 0
- Android widget之AppCompatButton
- 【Android笔记-异常-2】Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatButton c
- Android widget 之RemoteView
- Android widget 之RemoteView
- android widget之TextView
- android widget 之EditText
- android widget 之CheckBox
- Android之Widget
- Android widget 之RemoteView
- android--widget之menu
- Android widget 之RemoteView
- android之widget
- Android之Widget!!!!!!!!!!!!!!!!!
- Android widget 之RemoteView
- android学习之widget
- Android之Widget应用
- Android之Widget
- Android widget 之RemoteView
- 等腰三角形的打印
- 8.8.4
- 线段树从零开始
- C++数独求解器与生成器
- 【faster-rcnn】训练自己的数据集时的坑
- Android widget之AppCompatButton
- 白话CTC(connectionist temporal classification)算法讲解
- 小程序中布局的Html布局flexbox
- Android动画小结
- jmeter jdbc连接MySQL出现异常处理
- python2中为什么while 1比while True快
- C语言,素数和
- 对于 出现Missing parentheses in call to ‘print’和’raw_input’ is not defined问题的解决
- linux fl2440 kernel 移植