Android Persist TextView Text on Screen Rotation

June 17, 2018
freezesText=true

EditText's text can survive screen rotation by default. For TextView to persist text on configuration change (screen rotation), set freezesText=true

android:freezesText

If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. By default this is disabled; it can be useful when the contents of a text view is not stored in a persistent place such as a content provider. For EditText it is always enabled, regardless of the value of the attribute.

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:freezesText="true"
    />
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.