你告诉EditText到fill_parent,因此它填满了屏幕(整个宽度,没有为你的按钮留出空间).
您希望按钮包装其内容和编辑文本以填充余数,您可以使用layout_weight属性执行此操作:
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:gravity="center_vertical"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:orientation="horizontal">
android:id="@+id/searchField"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="10dip"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:radius="5dip"
android:inputType="textVisiblePassword"
android:textColor="#000000" />
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text="Blah" />
(我把你的可绘制参考文献用于其他人的通用)
另一方面,不要让你的XML在eclipse中看起来更整洁,更易于维护:
Window > Preferences > XML > XML Files > Editor
Line width 120
Split multiple attributes TICK
Align final bracket UNTICK
Preserve Whitespace tags in PCDATA UNTICK
Clear all blank lines UNTICK
Insert Whitespace before closing TICK
Click ok
然后你可以修复你的XML文件,当你打开一个XML文件CTRL A然后CTRL SHIFT F将很好地格式化它!