// The default attributes must be determined dynamically since whether // we use match_parent or fill_parent depends on the API level of the // project @Override String getDefaultAttrs(IProject project, String root) { Sdk currentSdk = Sdk.getCurrent(); String fill = VALUE_FILL_PARENT; if (currentSdk != null) { IAndroidTarget target = currentSdk.getTarget(project); // fill_parent was renamed match_parent in API level 8 if (target != null && target.getVersion().getApiLevel() >= 8) { fill = VALUE_MATCH_PARENT; } } // Only set "vertical" orientation of LinearLayouts by default; // for GridLayouts for example we want to rely on the real default // of the layout String size = String.format( "android:layout_width=\"%1$s\"\n" //$NON-NLS-1$ + "android:layout_height=\"%2$s\"", //$NON-NLS-1$ fill, fill); if (LINEAR_LAYOUT.equals(root)) { return "android:orientation=\"vertical\"\n" + size; // $NON-NLS-1$ } else { return size; } }