2011-07-14 33 views
0

对准我现在有这在我的layout.xml的Android的ImageButton不是的EditText和Button

 <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的顶部像巴顿和EditText上没有对齐。另外两个很好地填满了高度,但ImageButton似乎向上突出。有任何想法吗?

+0

添加填充不会使按钮更新。 – Maurice

回答

1

尝试使用RelativeLayout。您可以将视图对齐到父项的边,顶部和底部或任何其他view

使用android:layout_alignParentTop="true"或类似的。

RelativeLayout中有大量可用的xml命令。

0

您还可以在线性布局的子项上设置布局权重属性。您可以设置编辑文本,图像按钮和按钮的权重,这将使您的组件在屏幕上对齐。

+0

这只影响小部件大小而不是对齐。 – Maurice

相关问题