aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-11-20 22:12:55 +0100
committerTor Norbye <tnorbye@google.com>2011-12-22 11:43:28 -0800
commit51ff6d71ec293b76b7d770053832aa952d0889fa (patch)
tree4fb8df0f101552d43185f90691d209fdd3e14b4c
parentab36f4e7488358dea4ab6b54ee2b7bef3da0232b (diff)
downloadsdk-51ff6d71ec293b76b7d770053832aa952d0889fa.zip
sdk-51ff6d71ec293b76b7d770053832aa952d0889fa.tar.gz
sdk-51ff6d71ec293b76b7d770053832aa952d0889fa.tar.bz2
Set android:ems="10" for EditTexts on drop
Text fields (without a text attribute) has by default only a single character visible. To work around this, we automatically set the layout_width to match_parent instead of wrap_content in LinearLayouts, but in RelativeLayout and GridLayout etc (and in general) we don't have this, so text fields show up with a not particularly usable size. By setting the ems attribute to 10, the wrap_content size of the text field will show 10 characters which seems like a reasonable default (and when editing the XML or properties it's more obvious what you'd want to modify to get a different size, if not match_parent. Change-Id: Ic0460cea7810076b416f6d7d25a683851465ee9b
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java1
2 files changed, 7 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java
index 4f76111..7407854 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java
@@ -16,6 +16,8 @@
package com.android.ide.common.layout;
+import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI;
+import static com.android.ide.common.layout.LayoutConstants.ATTR_EMS;
import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.REQUEST_FOCUS;
import com.android.ide.common.api.IMenuCallback;
@@ -42,6 +44,10 @@ public class EditTextRule extends BaseViewRule {
// Add <requestFocus>
node.appendChild(REQUEST_FOCUS);
}
+
+ if (parent.getBounds().w >= 320) {
+ node.setAttribute(ANDROID_URI, ATTR_EMS, "10"); //$NON-NLS-1$
+ }
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java
index e47bb5b..c6a5ba8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LayoutConstants.java
@@ -251,6 +251,7 @@ public class LayoutConstants {
public static final String ATTR_WEIGHT_SUM = "weightSum"; //$NON-NLS-1$
public static final String ATTR_BASELINE_ALIGNED = "baselineAligned"; //$NON-NLS-1$
public static String ATTR_ORIENTATION = "orientation"; //$NON-NLS-1$
+ public static String ATTR_EMS = "ems"; //$NON-NLS-1$
public static String VALUE_HORIZONTAL = "horizontal"; //$NON-NLS-1$