---
title: "toAndroidRect"
description: "Creates a new instance of [android.graphics.Rect] with the same bounds specified in the given
[Rect]"
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-android'>Android</div>


> **Deprecated** Converting Rect to android.graphics.Rect is lossy, and requires rounding. The behavior of toAndroidRect() truncates to an integral Rect, but you should choose the method of rounding most suitable for your use case.

```kotlin
fun Rect.toAndroidRect(): android.graphics.Rect
```


Creates a new instance of `android.graphics.Rect` with the same bounds specified in the given
`Rect`



<div class='sourceset sourceset-android'>Android</div>


```kotlin
fun IntRect.toAndroidRect(): android.graphics.Rect
```


Creates a new instance of `android.graphics.Rect` with the same bounds specified in the given
`IntRect`



