Can you set graphical layout preview-only text on a TextView? Can you set graphical layout preview-only text on a TextView? android android

Can you set graphical layout preview-only text on a TextView?


Yes you can with the design tools extension attributes in Android Studio.

See this page https://developer.android.com/studio/write/tool-attributes.html

Basically you define the tools namespace

 xmlns:tools="http://schemas.android.com/tools"

Then use it to set your placeholder text.

<EditText         tools:text="John Doe"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />

This actually works with most (if not all xml attributes).

e.g

tools:visibility="gone"

would set the preview visibility to "gone" but the runtime visibility would be unchanged.


I don't believe there is, the only possible way is when you declare your TextView, you say after, tv.setText(""); this way you will always find it blank at runtime