public final class PointerIcon
extends Object implements Parcelable
| java.lang.Object | |
| android.view.PointerIcon | |
表示可以用作鼠标指针的图标。
指针图标可以由系统使用系统类型提供,也可以由使用位图或应用程序资源的应用程序提供。
常量(Constants) |
|
|---|---|
int |
TYPE_ALIAS 类型常量:别名(指示别名/快捷方式将被创建。 |
int |
TYPE_ALL_SCROLL 类型常量:全滚动。 |
int |
TYPE_ARROW 类型常量:箭头图标。 |
int |
TYPE_CELL 类型常量:单元格。 |
int |
TYPE_CONTEXT_MENU 类型常量:上下文菜单。 |
int |
TYPE_COPY 类型常量:复制。 |
int |
TYPE_CROSSHAIR 类型常量:十字准线。 |
int |
TYPE_DEFAULT 默认的指针图标。 |
int |
TYPE_GRAB 类型常量:抓取。 |
int |
TYPE_GRABBING 类型常量:抓取。 |
int |
TYPE_HAND 类型常量:手。 |
int |
TYPE_HELP 输入常量:帮助。 |
int |
TYPE_HORIZONTAL_DOUBLE_ARROW 类型常量:水平双箭头主要用于调整大小。 |
int |
TYPE_NO_DROP 类型常量:不降。 |
int |
TYPE_NULL 类型常量:空图标。 |
int |
TYPE_TEXT 键入常量:文本。 |
int |
TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW 类型常量:对角线双箭头 - 从左上角到右下角。 |
int |
TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW 类型常量:对角线双箭头 - 从右上角到左下角。 |
int |
TYPE_VERTICAL_DOUBLE_ARROW 类型常量:垂直双箭头主要用于调整大小。 |
int |
TYPE_VERTICAL_TEXT 类型常量:垂直文本。 |
int |
TYPE_WAIT 类型常量:等待。 |
int |
TYPE_ZOOM_IN 类型常量:放大。 |
int |
TYPE_ZOOM_OUT 类型常量:缩小。 |
Inherited constants |
|---|
android.os.Parcelable
|
Fields |
|
|---|---|
public static final Creator<PointerIcon> |
CREATOR |
公共方法(Public methods) |
|
|---|---|
static PointerIcon |
create(Bitmap bitmap, float hotSpotX, float hotSpotY) 根据给定的位图和热点信息创建一个自定义指针图标。 |
int |
describeContents() 描述此Parcelable实例的封送表示中包含的特殊对象的种类。 |
boolean |
equals(Object other) 指示其他某个对象是否“等于”这一个。 |
static PointerIcon |
getSystemIcon(Context context, int type) 获取给定类型的系统指针图标。 |
static PointerIcon |
load(Resources resources, int resourceId) 从XML资源加载自定义指针图标。 |
void |
writeToParcel(Parcel out, int flags) 将此对象平铺到一个包裹中。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
android.os.Parcelable
|
|
int TYPE_HORIZONTAL_DOUBLE_ARROW
类型常量:水平双箭头主要用于调整大小。
常量值:1014(0x000003f6)
int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW
类型常量:对角线双箭头 - 从左上角到右下角。
常量值:1017(0x000003f9)
int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW
类型常量:对角线双箭头 - 从右上角到左下角。
常量值:1016(0x000003f8)
int TYPE_VERTICAL_DOUBLE_ARROW
类型常量:垂直双箭头主要用于调整大小。
常量值:1015(0x000003f7)
PointerIcon create (Bitmap bitmap, float hotSpotX, float hotSpotY)
根据给定的位图和热点信息创建一个自定义指针图标。
| 参数(Parameters) | |
|---|---|
bitmap |
Bitmap: The bitmap for the icon. |
hotSpotX |
float: The X offset of the pointer icon hotspot in the bitmap. Must be within the [0, bitmap.getWidth()) range. |
hotSpotY |
float: The Y offset of the pointer icon hotspot in the bitmap. Must be within the [0, bitmap.getHeight()) range. |
| 返回(Returns) | |
|---|---|
PointerIcon |
A pointer icon for this bitmap. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if bitmap is null, or if the x/y hotspot parameters are invalid. |
int describeContents ()
描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象将在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。
| 返回(Returns) | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
boolean equals (Object other)
指示其他某个对象是否“等于”这一个。
equals方法在非空对象引用上实现等价关系:
x, x.equals(x) should return true. x and y, x.equals(y) should return true if and only if y.equals(x) returns true. x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified. x, x.equals(null) should return false. 类Object的equals方法实现了对象上最可能的等价关系; 也就是说,对于任何非空参考值x和y ,此方法返回true当且仅当x和y引用同一对象( x == y的值为true )。
请注意,无论何时重写此方法,通常都需要重写 hashCode方法,以便维护 hashCode方法的常规协定,该方法声明相等对象必须具有相同的哈希码。
| 参数(Parameters) | |
|---|---|
other |
Object: the reference object with which to compare. |
| 返回(Returns) | |
|---|---|
boolean |
true if this object is the same as the obj argument; false otherwise. |
PointerIcon getSystemIcon (Context context, int type)
获取给定类型的系统指针图标。 如果typeis未被识别,则返回默认指针图标。
| 参数(Parameters) | |
|---|---|
context |
Context: The context. |
type |
int: The pointer icon type. |
| 返回(Returns) | |
|---|---|
PointerIcon |
The pointer icon. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if context is null. |
PointerIcon load (Resources resources, int resourceId)
从XML资源加载自定义指针图标。
XML资源应该具有以下形式: <?xml version="1.0" encoding="utf-8"?> <pointer-icon xmlns:android="http://schemas.android.com/apk/res/android" android:bitmap="@drawable/my_pointer_bitmap" android:hotSpotX="24" android:hotSpotY="24" />
| 参数(Parameters) | |
|---|---|
resources |
Resources: The resources object. |
resourceId |
int: The resource id. |
| 返回(Returns) | |
|---|---|
PointerIcon |
The pointer icon. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if resources is null. |
|
if the resource was not found or the drawable linked in the resource was not found. |
void writeToParcel (Parcel out, int flags)
将此对象平铺到一个包裹中。
| 参数(Parameters) | |
|---|---|
out |
Parcel: The Parcel in which the object should be written. |
flags |
int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. |