Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/widget/Magnifier#nestedclasses) \| [Constants](https://developer.android.com/reference/android/widget/Magnifier#constants) \| [Ctors](https://developer.android.com/reference/android/widget/Magnifier#pubctors) \| [Methods](https://developer.android.com/reference/android/widget/Magnifier#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/widget/Magnifier#inhmethods)

# Magnifier

*** ** * ** ***

` public final class Magnifier `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.widget.Magnifier |

<br />

*** ** * ** ***

Android magnifier widget. Can be used by any view which is attached to a window.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/widget/Magnifier.Builder` Builder class for `https://developer.android.com/reference/android/widget/Magnifier` objects. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/widget/Magnifier#SOURCE_BOUND_MAX_IN_SURFACE` A source bound that will extend as much as possible, while remaining within the surface the content is copied from. |
| `int` | `https://developer.android.com/reference/android/widget/Magnifier#SOURCE_BOUND_MAX_VISIBLE` A source bound that will extend as much as possible, while remaining within the visible region of the magnified view, as determined by `https://developer.android.com/reference/android/view/View#getGlobalVisibleRect(android.graphics.Rect)`. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/widget/Magnifier#Magnifier(android.view.View)(https://developer.android.com/reference/android/view/View view) ` *This constructor is deprecated. Please use `https://developer.android.com/reference/android/widget/Magnifier.Builder` instead* |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/widget/Magnifier#dismiss()() ` Dismisses the magnifier from the screen. |
| ` float` | ` https://developer.android.com/reference/android/widget/Magnifier#getCornerRadius()() ` The units of this value are pixels. |
| ` int` | ` https://developer.android.com/reference/android/widget/Magnifier#getDefaultHorizontalSourceToMagnifierOffset()() ` Returns the horizontal offset, in pixels, to be applied to the source center position to obtain the magnifier center position when `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` is called. |
| ` int` | ` https://developer.android.com/reference/android/widget/Magnifier#getDefaultVerticalSourceToMagnifierOffset()() ` Returns the vertical offset, in pixels, to be applied to the source center position to obtain the magnifier center position when `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` is called. |
| ` float` | ` https://developer.android.com/reference/android/widget/Magnifier#getElevation()() ` The units of this value are pixels. |
| ` int` | ` https://developer.android.com/reference/android/widget/Magnifier#getHeight()() ` The units of this value are pixels. |
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/widget/Magnifier#getOverlay()() ` Returns the overlay to be drawn on the top of the magnifier, or `null` if no overlay should be drawn. |
| ` https://developer.android.com/reference/android/graphics/Point` | ` https://developer.android.com/reference/android/widget/Magnifier#getPosition()() ` Returns the top left coordinates of the magnifier, relative to the main application window. |
| ` int` | ` https://developer.android.com/reference/android/widget/Magnifier#getSourceHeight()() ` The units of this value are pixels. |
| ` https://developer.android.com/reference/android/graphics/Point` | ` https://developer.android.com/reference/android/widget/Magnifier#getSourcePosition()() ` Returns the top left coordinates of the magnifier source (i.e. |
| ` int` | ` https://developer.android.com/reference/android/widget/Magnifier#getSourceWidth()() ` The units of this value are pixels. |
| ` int` | ` https://developer.android.com/reference/android/widget/Magnifier#getWidth()() ` The units of this value are pixels. |
| ` float` | ` https://developer.android.com/reference/android/widget/Magnifier#getZoom()() ` Returns the zoom to be applied to the magnified view region copied to the magnifier. |
| ` boolean` | ` https://developer.android.com/reference/android/widget/Magnifier#isClippingEnabled()() ` Returns whether the magnifier position will be adjusted such that the magnifier will be fully within the bounds of the main application window, by also avoiding any overlap with system insets (such as the one corresponding to the status bar) i.e. |
| ` void` | ` https://developer.android.com/reference/android/widget/Magnifier#setZoom(float)(float zoom) ` Sets the zoom to be applied to the chosen content before being copied to the magnifier popup. |
| ` void` | ` https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)(float sourceCenterX, float sourceCenterY, float magnifierCenterX, float magnifierCenterY) ` Shows the magnifier on the screen at a position that is independent from its content position. |
| ` void` | ` https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)(float sourceCenterX, float sourceCenterY) ` Shows the magnifier on the screen. |
| ` void` | ` https://developer.android.com/reference/android/widget/Magnifier#update()() ` Asks the magnifier to update its content. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### SOURCE_BOUND_MAX_IN_SURFACE

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SOURCE_BOUND_MAX_IN_SURFACE
```

A source bound that will extend as much as possible, while remaining within the surface the content is copied from.

<br />

Constant Value: 0 (0x00000000)

### SOURCE_BOUND_MAX_VISIBLE

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SOURCE_BOUND_MAX_VISIBLE
```

A source bound that will extend as much as possible, while remaining within the visible region of the magnified view, as determined by `https://developer.android.com/reference/android/view/View#getGlobalVisibleRect(android.graphics.Rect)`.

<br />

Constant Value: 1 (0x00000001)

## Public constructors

### Magnifier

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Magnifier (View view)
```

<br />

**This constructor is deprecated.**   

Please use `https://developer.android.com/reference/android/widget/Magnifier.Builder` instead

Initializes a magnifier.

<br />

| Parameters ||
|---|---|
| `view` | `View`: the view for which this magnifier is attached. This value cannot be `null`. <br /> |

## Public methods

### dismiss

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dismiss ()
```

Dismisses the magnifier from the screen. Calling this on a dismissed magnifier is a no-op.

<br />

### getCornerRadius

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getCornerRadius ()
```

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `float` | the corner radius of the magnifier window, in pixels. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setCornerRadius(float)`

### getDefaultHorizontalSourceToMagnifierOffset

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getDefaultHorizontalSourceToMagnifierOffset ()
```

Returns the horizontal offset, in pixels, to be applied to the source center position to obtain the magnifier center position when `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` is called. The value is ignored when `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)` is used instead.   

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `int` | the default horizontal offset between the source center and the magnifier. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setDefaultSourceToMagnifierOffset(int,%20int)`
- `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)`

### getDefaultVerticalSourceToMagnifierOffset

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getDefaultVerticalSourceToMagnifierOffset ()
```

Returns the vertical offset, in pixels, to be applied to the source center position to obtain the magnifier center position when `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` is called. The value is ignored when `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)` is used instead.   

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `int` | the default vertical offset between the source center and the magnifier. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setDefaultSourceToMagnifierOffset(int,%20int)`
- `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)`

### getElevation

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getElevation ()
```

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `float` | the elevation set for the magnifier window, in pixels. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setElevation(float)`

### getHeight

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getHeight ()
```

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `int` | the height of the magnifier window, in pixels. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setSize(int,%20int)`

### getOverlay

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Drawable getOverlay ()
```

Returns the overlay to be drawn on the top of the magnifier, or `null` if no overlay should be drawn.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | the overlay <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setOverlay(android.graphics.drawable.Drawable)`

### getPosition

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Point getPosition ()
```

Returns the top left coordinates of the magnifier, relative to the main application window. They will be determined by the coordinates of the last `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` or `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)` call, adjusted to take into account any potential clamping behavior. The method can be used immediately after a #show call to find out where the magnifier will be positioned. However, the position of the magnifier will not be updated visually in the same frame, due to the async nature of the content copying and of the magnifier rendering. The method will return `null` if #show has not yet been called, or if the last operation performed was a #dismiss.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Point` | the top left coordinates of the magnifier <br /> |

### getSourceHeight

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSourceHeight ()
```

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `int` | the initial height of the content magnified and copied to the magnifier, in pixels. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setSize(int,%20int)`
- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setInitialZoom(float)`

### getSourcePosition

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Point getSourcePosition ()
```

Returns the top left coordinates of the magnifier source (i.e. the view region going to be magnified and copied to the magnifier), relative to the window or surface the content is copied from. The content will be copied: - if the magnified view is a `https://developer.android.com/reference/android/view/SurfaceView`, from the surface backing it - otherwise, from the surface backing the main application window, and the coordinates returned will be relative to the main application window The method will return `null` if #show has not yet been called, or if the last operation performed was a #dismiss.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Point` | the top left coordinates of the magnifier source <br /> |

### getSourceWidth

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSourceWidth ()
```

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `int` | the initial width of the content magnified and copied to the magnifier, in pixels. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setSize(int,%20int)`
- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setInitialZoom(float)`

### getWidth

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getWidth ()
```

The units of this value are pixels.

<br />

| Returns ||
|---|---|
| `int` | the width of the magnifier window, in pixels. The units of this value are pixels. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setSize(int,%20int)`

### getZoom

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float getZoom ()
```

Returns the zoom to be applied to the magnified view region copied to the magnifier. If the zoom is x and the magnifier window size is (width, height), the original size of the content being magnified will be (width / x, height / x).

<br />

| Returns ||
|---|---|
| `float` | the zoom applied to the content <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setInitialZoom(float)`

### isClippingEnabled

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isClippingEnabled ()
```

Returns whether the magnifier position will be adjusted such that the magnifier will be fully within the bounds of the main application window, by also avoiding any overlap with system insets (such as the one corresponding to the status bar) i.e. whether the area where the magnifier can be positioned will be clipped to the main application window and the system insets.

<br />

| Returns ||
|---|---|
| `boolean` | whether the magnifier position will be adjusted <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setClippingEnabled(boolean)`

### setZoom

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setZoom (float zoom)
```

Sets the zoom to be applied to the chosen content before being copied to the magnifier popup. The change will become effective at the next #show or #update call.

<br />

| Parameters ||
|---|---|
| `zoom` | `float`: the zoom to be set. Value is 0.0f or greater <br /> |

### show

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void show (float sourceCenterX, 
                float sourceCenterY, 
                float magnifierCenterX, 
                float magnifierCenterY)
```

Shows the magnifier on the screen at a position that is independent from its content position. The first two arguments represent the coordinates of the center of the content source going to be magnified and copied to the magnifier. The last two arguments represent the coordinates of the center of the magnifier itself. All four coordinates are relative to the top left corner of the magnified view. If you consider using this method such that the offset between the source center and the magnifier center coordinates remains constant, you should consider using method `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` instead.

<br />

| Parameters ||
|---|---|
| `sourceCenterX` | `float`: horizontal coordinate of the source center relative to the view. Value is 0.0f or greater <br /> |
| `sourceCenterY` | `float`: vertical coordinate of the source center, relative to the view. Value is 0.0f or greater <br /> |
| `magnifierCenterX` | `float`: horizontal coordinate of the magnifier center, relative to the view <br /> |
| `magnifierCenterY` | `float`: vertical coordinate of the magnifier center, relative to the view <br /> |

### show

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void show (float sourceCenterX, 
                float sourceCenterY)
```

Shows the magnifier on the screen. The method takes the coordinates of the center of the content source going to be magnified and copied to the magnifier. The coordinates are relative to the top left corner of the magnified view. The magnifier will be positioned such that its center will be at the default offset from the center of the source. The default offset can be specified using the method `https://developer.android.com/reference/android/widget/Magnifier.Builder#setDefaultSourceToMagnifierOffset(int,%20int)`. If the offset should be different across calls to this method, you should consider to use method `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)` instead.

<br />

| Parameters ||
|---|---|
| `sourceCenterX` | `float`: horizontal coordinate of the source center, relative to the view. Value is 0.0f or greater <br /> |
| `sourceCenterY` | `float`: vertical coordinate of the source center, relative to the view. Value is 0.0f or greater <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/Magnifier.Builder#setDefaultSourceToMagnifierOffset(int,%20int)`
- `https://developer.android.com/reference/android/widget/Magnifier#getDefaultHorizontalSourceToMagnifierOffset()`
- `https://developer.android.com/reference/android/widget/Magnifier#getDefaultVerticalSourceToMagnifierOffset()`
- `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)`

### update

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void update ()
```

Asks the magnifier to update its content. It uses the previous coordinates passed to `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float)` or `https://developer.android.com/reference/android/widget/Magnifier#show(float,%20float,%20float,%20float)`. The method only has effect if the magnifier is currently showing.

<br />