Home > DeveloperSection > Forums > What's “tools:context” in Android layout files?
Royce Roy
Royce Roy

Total Post:149

Posted on    June-11-2015 1:14 AM

 Android Android 

 1 Reply(s)
 1677  View(s)
Rate this:
Starting with a recent new version of ADT, I've noticed this new attribute on the layout XML files, for example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    tools:context=".MainActivity" />
What is "tools:context" used for?

How does it even know the exact path to the activity that is written there? Does it look at the package of the app, inside the manifest?

Is it limited to classes that extend Context or only activities? Is it usable for ListView items etc.?

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    June-11-2015 8:33 AM

This is most probably the activity the tools UI editor uses to render your layout (it will find the right theme based on the activity). This is documented here (around the middle of the article; subscribe to that page to keep up to date).

Don't want to miss updates? Please click the below button!

Follow MindStick