PointerIconCompat

Added in 1.1.0

public final class PointerIconCompat


Helper for accessing features in PointerIcon in a backwards compatible fashion.

Summary

Constants

static final int
TYPE_ALIAS = 1010

Synonym for TYPE_ALIAS

static final int

Synonym for TYPE_ALL_SCROLL

static final int
TYPE_ARROW = 1000

Synonym for TYPE_ARROW

static final int
TYPE_CELL = 1006

Synonym for TYPE_CELL

static final int

Synonym for TYPE_CONTEXT_MENU

static final int
TYPE_COPY = 1011

Synonym for TYPE_COPY

static final int

Synonym for TYPE_CROSSHAIR

static final int

Synonym for TYPE_DEFAULT

static final int
TYPE_GRAB = 1020

Synonym for TYPE_GRAB

static final int

Synonym for TYPE_GRABBING

static final int
TYPE_HAND = 1002

Synonym for TYPE_HAND

static final int
TYPE_HELP = 1003

Synonym for TYPE_HELP

static final int

Synonym for TYPE_HORIZONTAL_DOUBLE_ARROW

static final int

Synonym for TYPE_NO_DROP

static final int

Synonym for TYPE_NULL

static final int
TYPE_TEXT = 1008

Synonym for TYPE_TEXT

static final int

Synonym for TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW

static final int

Synonym for TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW

static final int

Synonym for TYPE_VERTICAL_DOUBLE_ARROW

static final int

Synonym for TYPE_VERTICAL_TEXT

static final int
TYPE_WAIT = 1004

Synonym for TYPE_WAIT

static final int

Synonym for TYPE_ZOOM_IN

static final int

Synonym for TYPE_ZOOM_OUT

Public methods

static @NonNull PointerIconCompat
create(@NonNull Bitmap bitmap, float hotSpotX, float hotSpotY)

Creates a custom pointer from the given bitmap and hotspot information.

static @NonNull PointerIconCompat
getSystemIcon(@NonNull Context context, int style)

Gets a system pointer icon for the given style.

static @NonNull PointerIconCompat
load(@NonNull Resources resources, int resourceId)

Loads a custom pointer icon from an XML resource.

Constants

TYPE_ALIAS

Added in 1.1.0
public static final int TYPE_ALIAS = 1010

Synonym for TYPE_ALIAS

TYPE_ALL_SCROLL

Added in 1.1.0
public static final int TYPE_ALL_SCROLL = 1013

Synonym for TYPE_ALL_SCROLL

TYPE_ARROW

Added in 1.1.0
public static final int TYPE_ARROW = 1000

Synonym for TYPE_ARROW

TYPE_CELL

Added in 1.1.0
public static final int TYPE_CELL = 1006

Synonym for TYPE_CELL

TYPE_CONTEXT_MENU

Added in 1.1.0
public static final int TYPE_CONTEXT_MENU = 1001

Synonym for TYPE_CONTEXT_MENU

TYPE_COPY

Added in 1.1.0
public static final int TYPE_COPY = 1011

Synonym for TYPE_COPY

TYPE_CROSSHAIR

Added in 1.1.0
public static final int TYPE_CROSSHAIR = 1007

Synonym for TYPE_CROSSHAIR

TYPE_DEFAULT

Added in 1.1.0
public static final int TYPE_DEFAULT = 1000

Synonym for TYPE_DEFAULT

TYPE_GRAB

Added in 1.1.0
public static final int TYPE_GRAB = 1020

Synonym for TYPE_GRAB

TYPE_GRABBING

Added in 1.1.0
public static final int TYPE_GRABBING = 1021

Synonym for TYPE_GRABBING

TYPE_HAND

Added in 1.1.0
public static final int TYPE_HAND = 1002

Synonym for TYPE_HAND

TYPE_HELP

Added in 1.1.0
public static final int TYPE_HELP = 1003

Synonym for TYPE_HELP

TYPE_HORIZONTAL_DOUBLE_ARROW

Added in 1.1.0
public static final int TYPE_HORIZONTAL_DOUBLE_ARROW = 1014

Synonym for TYPE_HORIZONTAL_DOUBLE_ARROW

TYPE_NO_DROP

Added in 1.1.0
public static final int TYPE_NO_DROP = 1012

Synonym for TYPE_NO_DROP

TYPE_NULL

Added in 1.1.0
public static final int TYPE_NULL = 0

Synonym for TYPE_NULL

TYPE_TEXT

Added in 1.1.0
public static final int TYPE_TEXT = 1008

Synonym for TYPE_TEXT

TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW

Added in 1.1.0
public static final int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017

Synonym for TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW

TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW

Added in 1.1.0
public static final int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016

Synonym for TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW

TYPE_VERTICAL_DOUBLE_ARROW

Added in 1.1.0
public static final int TYPE_VERTICAL_DOUBLE_ARROW = 1015

Synonym for TYPE_VERTICAL_DOUBLE_ARROW

TYPE_VERTICAL_TEXT

Added in 1.1.0
public static final int TYPE_VERTICAL_TEXT = 1009

Synonym for TYPE_VERTICAL_TEXT

TYPE_WAIT

Added in 1.1.0
public static final int TYPE_WAIT = 1004

Synonym for TYPE_WAIT

TYPE_ZOOM_IN

Added in 1.1.0
public static final int TYPE_ZOOM_IN = 1018

Synonym for TYPE_ZOOM_IN

TYPE_ZOOM_OUT

Added in 1.1.0
public static final int TYPE_ZOOM_OUT = 1019

Synonym for TYPE_ZOOM_OUT

Public methods

create

Added in 1.1.0
public static @NonNull PointerIconCompat create(@NonNull Bitmap bitmap, float hotSpotX, float hotSpotY)

Creates a custom pointer from the given bitmap and hotspot information.

Parameters
@NonNull Bitmap bitmap

The bitmap for the icon.

float hotSpotX

The X offset of the pointer icon hotspot in the bitmap. Must be within the [0, bitmap.getWidth()) range.

float hotSpotY

The Y offset of the pointer icon hotspot in the bitmap. Must be within the [0, bitmap.getHeight()) range.

Returns
@NonNull PointerIconCompat

A pointer icon for this bitmap.

Throws
java.lang.IllegalArgumentException

if bitmap is null, or if the x/y hotspot parameters are invalid.

getSystemIcon

Added in 1.1.0
public static @NonNull PointerIconCompat getSystemIcon(@NonNull Context context, int style)

Gets a system pointer icon for the given style. If style is not recognized, returns the default pointer icon.

Parameters
@NonNull Context context

The context.

int style

The pointer icon style.

Returns
@NonNull PointerIconCompat

The pointer icon.

load

Added in 1.1.0
public static @NonNull PointerIconCompat load(@NonNull Resources resources, int resourceId)

Loads a custom pointer icon from an XML resource.

The XML resource should have the following form: <?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
@NonNull Resources resources

The resources object.

int resourceId

The resource id.

Returns
@NonNull PointerIconCompat

The pointer icon.

Throws
android.content.res.Resources.NotFoundException

if the resource was not found or the drawable linked in the resource was not found.