在 layout.xml 中设置:
<EditText android:id="@+id/body" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
android:hint="Type to compose" />
<ImageButton android:id="@+id/attach"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/attach_photo" />
<Button android:id="@+id/send" android:text="@string/send"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
现在遇到的问题是:ImageButton 的顶部显示不像 Button 和 EditText 那样。Button 和EditText 上的内容显示的时候,上下填充的很好。但是,ImageButton 上面的内容似乎向上突出了。如何设置按钮的显示呢?
使用一个 RelativeLayout
。你可以把视图向两边对齐,父类的顶端和底部或者别的视图。
使用android:layout_alignParentTop="true"
在 RelativeLayout 中有大量的 xml 命令。