81

Is it possible to create placeholder text that is only visible during the layout design process in Android Studio?

For example, say I have 2 TextViews in a linear layout that are going to be dynamically populated. During the design phase, I use placeholder text to ensure I get padding and such correct. I often forget to remove placeholder text, so during loading of the new data, the old data will appear for a split second... looks tacky.

It would be cool if there was a field similar to android:placeholderText="This is placeholder text" that would only display in the preview. There isn't such a thing that I've happened to have missed is there?

1 Answer 1

150

Yes it is (these days), and I believe that this is probably what you're looking for:
https://developer.android.com/studio/write/tool-attributes - specifically: tools:text=""

Sign up to request clarification or add additional context in comments.

3 Comments

Awesome. I knew I had seen that somewhere! For others, remember to include the namespace xmlns:tools="http://schemas.android.com/tools" in your root element.
this will work for most android: attributes - the 2nd most useful to text might be: tools:visibility="visible" to show normally-hidden elements in design view (or vice-versa)
I also frequently use tools:src for ImageViews used for displaying user avatars or other dynamic content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.