# Android studio layout preview with tools designtime attributes

DevFeed: [Android studio layout preview with tools designtime attributes](<https://devfeed.tech/articles/android-studio-layout-preview-with-tools-designtime-attributes-25828.md>)

Original publisher: [Read original article](<https://segunfamisa.com/posts/android-studio-design-time-attributes>)

Author: Segun Famisa

Published: 2016-09-08T21:42:45Z

Content type: tutorial

Language: en

Sources: [Segun Famisa](<https://devfeed.tech/sources/segun-famisa.md>)

Topics: [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Android](<https://devfeed.tech/topics/android.md>), [XML](<https://devfeed.tech/topics/xml.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [recyclerview](<https://devfeed.tech/tags/recyclerview.md>), [ui](<https://devfeed.tech/tags/ui.md>), [xml](<https://devfeed.tech/tags/xml.md>)

## AI overview

A short Android Studio tutorial explaining how to use tools design-time attributes in Android XML layouts to preview sample content without affecting app runtime. It covers declaring the tools namespace, replacing Android attributes for previews, and previewing list content.

## Source excerpt

This is a short tip for Android Studio users. Many people know this, but I thought to still share for those that don't know. As developers, when we're building a UI layout in Android, it's common desire to want to preview what we're designing right? We usually want to add that sample data, like android:text="Test Test" to see how exactly it will look in our layout. Many times, we forget to remove such sample data. It's even more stressful when you're building a list. You have to run the app to see what your list looks like. Well, designtime attributes are here to help. Designtime attributes? What are they? Designtime attributes are attributes that are used only in rendering the Android studio layout preview, they have no impact at runtime. Designtime attributes aren't new in Android studio. They've been around since Android Studio 0.2.11. Designtime attributes are specified by the use of the tools namespace in Android XML layouts. Using designtime attributes a. Declare tools namespace. To use the designtime attributes, you need to first declare the tools namespace within the root tag of your layout. Your layout will look something like: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" ... > ... </LinearLayout> All tools attributes get stripped out at compile time by AAPT, and that's how they have no effect at runtime. b. Replace android namespace with tools Now that you have declared the namespace, you can replace almost any android xml attribute with tools, for the designtime. For example, let's say we wanted to test our text wrapping and see how our textview would look with a very long text, we would do something like: <TextView android:layout_width="match_parent" android:layout_height="wrap_content" ... tools:text="Test test, let's add some really really really long text" /> Note the tools:text attribute we used instead of the usual android:text Interesting uses with listviews and recycler vie