Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/text/method/TransformationMethod#pubmethods)

# TransformationMethod

*** ** * ** ***

` public interface TransformationMethod `   
` `

|---|
| android.text.method.TransformationMethod |

Known indirect subclasses [HideReturnsTransformationMethod](https://developer.android.com/reference/android/text/method/HideReturnsTransformationMethod), [PasswordTransformationMethod](https://developer.android.com/reference/android/text/method/PasswordTransformationMethod), [ReplacementTransformationMethod](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod), [SingleLineTransformationMethod](https://developer.android.com/reference/android/text/method/SingleLineTransformationMethod) [HideReturnsTransformationMethod](https://developer.android.com/reference/android/text/method/HideReturnsTransformationMethod) This transformation method causes any carriage return characters (\\r) to be hidden by displaying them as zero-width non-breaking space characters (\\ufeff). [PasswordTransformationMethod](https://developer.android.com/reference/android/text/method/PasswordTransformationMethod) [ReplacementTransformationMethod](https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod) This transformation method causes the characters in the `https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getOriginal()` array to be replaced by the corresponding characters in the `https://developer.android.com/reference/android/text/method/ReplacementTransformationMethod#getReplacement()` array. [SingleLineTransformationMethod](https://developer.android.com/reference/android/text/method/SingleLineTransformationMethod) This transformation method causes any newline characters (\\n) to be displayed as spaces instead of causing line breaks, and causes carriage return characters (\\r) to have no appearance.   

*** ** * ** ***

TextView uses TransformationMethods to do things like replacing the characters of passwords with dots, or keeping the newline characters from causing line breaks in single-line text fields.

## Summary

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/text/method/TransformationMethod#getTransformation(java.lang.CharSequence,%20android.view.View)(https://developer.android.com/reference/java/lang/CharSequence source, https://developer.android.com/reference/android/view/View view) ` Returns a CharSequence that is a transformation of the source text -- for example, replacing each character with a dot in a password field. |
| ` abstract void` | ` https://developer.android.com/reference/android/text/method/TransformationMethod#onFocusChanged(android.view.View,%20java.lang.CharSequence,%20boolean,%20int,%20android.graphics.Rect)(https://developer.android.com/reference/android/view/View view, https://developer.android.com/reference/java/lang/CharSequence sourceText, boolean focused, int direction, https://developer.android.com/reference/android/graphics/Rect previouslyFocusedRect) ` This method is called when the TextView that uses this TransformationMethod gains or loses focus. |

## Public methods

### getTransformation

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

```
public abstract CharSequence getTransformation (CharSequence source, 
                View view)
```

Returns a CharSequence that is a transformation of the source text -- for example, replacing each character with a dot in a password field. Beware that the returned text must be exactly the same length as the source text, and that if the source text is Editable, the returned text must mirror it dynamically instead of doing a one-time copy. The method should not return `null` unless `source` is `null`.

<br />

| Parameters ||
|---|---|
| `source` | `CharSequence` <br /> |
| `view` | `View` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | <br /> |

### onFocusChanged

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

```
public abstract void onFocusChanged (View view, 
                CharSequence sourceText, 
                boolean focused, 
                int direction, 
                Rect previouslyFocusedRect)
```

This method is called when the TextView that uses this TransformationMethod gains or loses focus.

<br />

| Parameters ||
|---|---|
| `view` | `View` <br /> |
| `sourceText` | `CharSequence` <br /> |
| `focused` | `boolean` <br /> |
| `direction` | `int` <br /> |
| `previouslyFocusedRect` | `Rect` <br /> |