what are tools: context in layouts files?

5

Good morning everyone.

In some tutorials I've been seeing around, creators defined this property, 'tools: context' in the main layout manager of xmls. I looked in Ricardo Lecheta's book, but he does not use it at all.

So .. What is it and what is the purpose of defining this 'tools: context?'

Example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

Thank you!

    
asked by anonymous 07.07.2014 / 15:31

2 answers

3

Basically tools:context is used to tell you what Activity that the UI Editor should use to choose a theme to render its layout. And this is related to Activity Chooser in the IDE (Android Studio or Eclipse).

Response based on this Stack Overflow EN < sub>

    
07.07.2014 / 15:41
4

This attribute is used to map the layout to an activity.

For example. If your activity uses a custom theme you set this theme in the manifest, if you assign tools:context to this activity, when you put the Layout to edit in graphical view, theoretically layouts should apply the theme set for that activity to manifesto.

More details about the tools:... attribute login here .

    
07.07.2014 / 15:50