# Using sample data resources in Android Studio

DevFeed: [Using sample data resources in Android Studio](<https://devfeed.tech/articles/using-sample-data-resources-in-android-studio-25842.md>)

Original publisher: [Read original article](<https://segunfamisa.com/posts/sample-data-with-android-studio>)

Author: Segun Famisa

Published: 2018-10-01T09:00:00Z

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>), [Code](<https://devfeed.tech/topics/code.md>)

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

## AI overview

A tutorial on using sample data resources in Android Studio 3.2 to populate layout previews. It explains design-time tools attributes in XML and covers framework-provided and custom sample data.

## Source excerpt

Recently, Android Studio 3.2 became stable. The new release brings loads of goodies (explained in the release post here). One of the nice features that caught my attention was the support for Sample data. Using sample data in Android Studio isn't particularly a new feature. I first saw it in this year's Google I/O Android app that was open sourced. It has probably being around even longer. However, with the new Android Studio 3.2 it's even easier to use sample data in your projects. I took the feature for a spin and decided to share my findings. In this quick post, I'll be sharing how you can take advantage of sample data resources in your project. "Sample data" as you might guess, helps us to provide sample data to populate our fields when working with layouts in Android studio. It makes design previews with real data really neat and easy - we don't have to have hardcoded tool attribute values in our XML files. The tools: namespace and attributes You can use the tools namespace in most (if not all) places you can use the Android namespace within your layouts. In addition, you can also use the tools attributes for some error handling like tools:targetApi, and tools:ignore . If these view attributes (for example, textColor) are supported by the preview, you will be able to see your views with the attributes specified in the preview section of your layout editor. The code below shows the text colour as red in the layout preview. <TextView ... android:text="Hello World!" tools:textColor="#FF0000" /> The system only shows these values in the layout editor while designing, but ignores all view attributes that carry the tools namespace, which makes it really handy. It is also why they are also known as design time attributes. If you want to see more about tools/design time attributes, check out this post - https://segunfamisa.com/posts/android-studio-design-time-attributes Sample data One can typically use sample data in two ways. Either by using the sample data provided