Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does ${packageName}.${activityClass} work in layout XML files?

ADT now generates XML layouts with the following attributes:

<LinearLayout 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="${packageName}.${activityClass}" >

How do the design tools know which class it belongs to?

like image 407
Monstieur Avatar asked Jun 05 '14 12:06

Monstieur


1 Answers

My Eclipse ADT autogenerates the following:

<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="${relativePackage}.${activityClass}" >

</RelativeLayout>

My question is: "Is there an Eclipse ADT reference that lists and explains all of the available variables one can use with the Android Tools Attributes?"

For example, it would be nice to see something like:

  • relativePackage: resolves to the value of the package= attribute of the <manifest> element in the file "AndroidManifest.xml".
  • activityClass: resolves to the value of the android:name= attribute of the <activity> element in the file "AndroidManifest.xml".
  • etc. ...
  • ... with a list of any/all other variables available for use

I found some links related to the tools namespace, but none of them explain how Eclipse ADT resolves, for example, ${relativePackage}.

Android Tools Project Site

Tools Attributes -> shows the attributes available in the "tools" namespace

Designtime Layout Attributes -> shows some of the "how and why" you would use the attributes

StackOverflow Site

Android “tools” namespace in layout xml documentation -> shows abstraction of the attributes values into xml files

What's “tools:context” in Android layout files? -> shows a lot of good info on Tools Attributes, but gives no answer to my question "Is there an Eclipse ADT reference that lists ..."; it only shows tools:context=".MainActivity"

What's tools:layout in fragment xml file? -> gives a bit of insight into using Eclipse ADT Graphical Layout editor

like image 81
openmic Avatar answered Sep 18 '22 07:09

openmic