Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/view/View.DragShadowBuilder#pubctors) \| [Methods](https://developer.android.com/reference/android/view/View.DragShadowBuilder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/View.DragShadowBuilder#inhmethods)

# View.DragShadowBuilder

*** ** * ** ***

` public static class View.DragShadowBuilder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.View.DragShadowBuilder |

<br />

*** ** * ** ***

Creates an image that the system displays during the drag and drop operation. This is called a "drag shadow". The default implementation for a DragShadowBuilder based on a View returns an image that has exactly the same appearance as the given View. The default also positions the center of the drag shadow directly under the touch point. If no View is provided (the constructor with no parameters is used), and `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onProvideShadowMetrics(android.graphics.Point,%20android.graphics.Point)` and `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onDrawShadow(android.graphics.Canvas)` are not overridden, then the default is an invisible drag shadow.

You are not required to use the View you provide to the constructor as the basis of the drag shadow. The `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onDrawShadow(android.graphics.Canvas)` method allows you to draw anything you want as the drag shadow.

You pass a DragShadowBuilder object to the system when you start the drag. The system calls `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onProvideShadowMetrics(android.graphics.Point,%20android.graphics.Point)` to get the size and position of the drag shadow. It uses this data to construct a `https://developer.android.com/reference/android/graphics/Canvas` object, then it calls `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onDrawShadow(android.graphics.Canvas)` so that your application can draw the shadow image in the Canvas.

### Developer Guides

For a guide to implementing drag and drop features, read the [Drag and Drop](https://developer.android.com/guide/topics/ui/drag-drop) developer guide.

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/View.DragShadowBuilder#DragShadowBuilder()() ` Construct a shadow builder object with no associated View. |
| ` https://developer.android.com/reference/android/view/View.DragShadowBuilder#DragShadowBuilder(android.view.View)(https://developer.android.com/reference/android/view/View view) ` Constructs a shadow image builder based on a View. |

| ### Public methods ||
|---|---|
| ` final https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/view/View.DragShadowBuilder#getView()() ` Returns the View object that had been passed to the `https://developer.android.com/reference/android/view/View.DragShadowBuilder#DragShadowBuilder(android.view.View)` constructor. |
| ` void` | ` https://developer.android.com/reference/android/view/View.DragShadowBuilder#onDrawShadow(android.graphics.Canvas)(https://developer.android.com/reference/android/graphics/Canvas canvas) ` Draws the shadow image. |
| ` void` | ` https://developer.android.com/reference/android/view/View.DragShadowBuilder#onProvideShadowMetrics(android.graphics.Point,%20android.graphics.Point)(https://developer.android.com/reference/android/graphics/Point outShadowSize, https://developer.android.com/reference/android/graphics/Point outShadowTouchPoint) ` Provides the metrics for the shadow image. |

### 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*.

## Public constructors

### DragShadowBuilder

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

```
public DragShadowBuilder ()
```

Construct a shadow builder object with no associated View. This constructor variant is only useful when the `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onProvideShadowMetrics(android.graphics.Point,%20android.graphics.Point)` and `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onDrawShadow(android.graphics.Canvas)` methods are also overridden in order to supply the drag shadow's dimensions and appearance without reference to any View object.

<br />

### DragShadowBuilder

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

```
public DragShadowBuilder (View view)
```

Constructs a shadow image builder based on a View. By default, the resulting drag shadow will have the same appearance and dimensions as the View, with the touch point over the center of the View.

<br />

| Parameters ||
|---|---|
| `view` | `View`: A View. Any View in scope can be used. <br /> |

## Public methods

### getView

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

```
public final View getView ()
```

Returns the View object that had been passed to the `https://developer.android.com/reference/android/view/View.DragShadowBuilder#DragShadowBuilder(android.view.View)` constructor. If that View parameter was `null` or if the `https://developer.android.com/reference/android/view/View.DragShadowBuilder#DragShadowBuilder()` constructor was used to instantiate the builder object, this method will return null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The View object associate with this builder object. <br /> |

### onDrawShadow

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

```
public void onDrawShadow (Canvas canvas)
```

Draws the shadow image. The system creates the `https://developer.android.com/reference/android/graphics/Canvas` object based on the dimensions it received from the `https://developer.android.com/reference/android/view/View.DragShadowBuilder#onProvideShadowMetrics(android.graphics.Point,%20android.graphics.Point)` callback.

<br />

| Parameters ||
|---|---|
| `canvas` | `Canvas`: A `https://developer.android.com/reference/android/graphics/Canvas` object in which to draw the shadow image. This value cannot be `null`. <br /> |

### onProvideShadowMetrics

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

```
public void onProvideShadowMetrics (Point outShadowSize, 
                Point outShadowTouchPoint)
```

Provides the metrics for the shadow image. These include the dimensions of the shadow image, and the point within that shadow that should be centered under the touch location while dragging.

The default implementation sets the dimensions of the shadow to be the same as the dimensions of the View itself and centers the shadow under the touch point.

<br />

<br />

| Parameters ||
|---|---|
| `outShadowSize` | `Point`: A `https://developer.android.com/reference/android/graphics/Point` containing the width and height of the shadow image. Your application must set `https://developer.android.com/reference/android/graphics/Point#x` to the desired width and must set `https://developer.android.com/reference/android/graphics/Point#y` to the desired height of the image. Since Android P, the width and height must be positive values. <br /> |
| `outShadowTouchPoint` | `Point`: A `https://developer.android.com/reference/android/graphics/Point` for the position within the shadow image that should be underneath the touch point during the drag and drop operation. Your application must set `https://developer.android.com/reference/android/graphics/Point#x` to the X coordinate and `https://developer.android.com/reference/android/graphics/Point#y` to the Y coordinate of this position. <br /> |