PointerIconCompat
class PointerIconCompat
Helper for accessing features in PointerIcon in a backwards compatible fashion.
Summary
Public functions |
|
|---|---|
java-static PointerIconCompat |
Creates a custom pointer from the given bitmap and hotspot information. |
java-static PointerIconCompat |
getSystemIcon(context: Context, style: Int)Gets a system pointer icon for the given style. |
java-static PointerIconCompat |
Loads a custom pointer icon from an XML resource. |
Constants
TYPE_CONTEXT_MENU
const val TYPE_CONTEXT_MENU = 1001: Int
Synonym for TYPE_CONTEXT_MENU
TYPE_HORIZONTAL_DOUBLE_ARROW
const val TYPE_HORIZONTAL_DOUBLE_ARROW = 1014: Int
Synonym for TYPE_HORIZONTAL_DOUBLE_ARROW
TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW
const val TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017: Int
Synonym for TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW
TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW
const val TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016: Int
Synonym for TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW
TYPE_VERTICAL_DOUBLE_ARROW
const val TYPE_VERTICAL_DOUBLE_ARROW = 1015: Int
Synonym for TYPE_VERTICAL_DOUBLE_ARROW
TYPE_VERTICAL_TEXT
const val TYPE_VERTICAL_TEXT = 1009: Int
Synonym for TYPE_VERTICAL_TEXT
Public functions
create
java-static fun create(bitmap: Bitmap, hotSpotX: Float, hotSpotY: Float): PointerIconCompat
Creates a custom pointer from the given bitmap and hotspot information.
| 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 | |
|---|---|
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
java-static fun getSystemIcon(context: Context, style: Int): PointerIconCompat
Gets a system pointer icon for the given style. If style is not recognized, returns the default pointer icon.
| Returns | |
|---|---|
PointerIconCompat |
The pointer icon. |
load
java-static fun load(resources: Resources, resourceId: Int): PointerIconCompat
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" />
| Returns | |
|---|---|
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. |