# BidirectionalTypeConverter

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

# BidirectionalTypeConverter

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/animation/BidirectionalTypeConverter "View this page in Kotlin")\|Java

`
public


abstract
class
BidirectionalTypeConverter
`  
`


``

extends `[TypeConverter](https://developer.android.com/reference/android/animation/TypeConverter)`<T, V>


``


`

|---|---|------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.animation.TypeConverter](https://developer.android.com/reference/android/animation/TypeConverter)\<T, V\> ||
|   | ↳ | android.animation.BidirectionalTypeConverter\<T, V\> |

<br />

*** ** * ** ***

Abstract base class used convert type T to another type V and back again. This is necessary when the value types of in animation are different from the property type. BidirectionalTypeConverter is needed when only the final value for the animation is supplied to animators.  
**See also:**

- [PropertyValuesHolder.setConverter(TypeConverter)](https://developer.android.com/reference/android/animation/PropertyValuesHolder#setConverter(android.animation.TypeConverter))

## Summary

|                                                                                                                                                                     ### Public constructors                                                                                                                                                                      ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[BidirectionalTypeConverter](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter#BidirectionalTypeConverter(java.lang.Class<T>,%20java.lang.Class<V>))`(`[Class](https://developer.android.com/reference/java/lang/Class)`<T> fromClass, `[Class](https://developer.android.com/reference/java/lang/Class)`<V> toClass) ` |

|                                                                                                                                                        ### Public methods                                                                                                                                                         ||
|-------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract T`                                                                                                                 | ` `[convertBack](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter#convertBack(V))`(V value) ` Does a conversion from the target type back to the source type.  |
| ` `[BidirectionalTypeConverter](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter)`<V, T>` | ` `[invert](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter#invert())`() ` Returns the inverse of this converter, where the from and to classes are reversed. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.animation.TypeConverter](https://developer.android.com/reference/android/animation/TypeConverter)` ` |---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract V` | ` `[convert](https://developer.android.com/reference/android/animation/TypeConverter#convert(T))`(T value) ` Converts a value from one type to another. | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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

### BidirectionalTypeConverter

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

```
public BidirectionalTypeConverter (Class<T> fromClass, 
                Class<V> toClass)
```

<br />

<br />

|         Parameters          ||
|-------------|----------------|
| `fromClass` | `Class` <br /> |
| `toClass`   | `Class` <br /> |

## Public methods

### convertBack

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

```
public abstract T convertBack (V value)
```

Does a conversion from the target type back to the source type. The subclass must implement this when a TypeConverter is used in animations and current values will need to be read for an animation.

<br />

|                 Parameters                  ||
|---------|------------------------------------|
| `value` | `V`: The Object to convert. <br /> |

|                        Returns                        ||
|-----|--------------------------------------------------|
| `T` | A value of type T, converted from`value`. <br /> |

### invert

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

```
public BidirectionalTypeConverter<V, T> invert ()
```

Returns the inverse of this converter, where the from and to classes are reversed. The inverted converter uses this convert to call[convertBack(java.lang.Object)](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter#convertBack(V))for[TypeConverter.convert(java.lang.Object)](https://developer.android.com/reference/android/animation/TypeConverter#convert(T))calls and[TypeConverter.convert(java.lang.Object)](https://developer.android.com/reference/android/animation/TypeConverter#convert(T))for[convertBack(java.lang.Object)](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter#convertBack(V))calls.

<br />

|                                                                                                    Returns                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [BidirectionalTypeConverter](https://developer.android.com/reference/android/animation/BidirectionalTypeConverter)`<V, T>` | The inverse of this converter, where the from and to classes are reversed. <br /> |