我有一个EditText上,并在相对布局的按钮的作用。下面是XML:机器人:layout_centerVerticle =“真”没有对我的编辑文本
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5sp" >
<Button
android:id="@+id/action_home_button"
android:layout_width="35sp"
android:layout_height="35sp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@drawable/home_button" />
<EditText
android:id="@+id/action_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/action_home_button"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Some hint..."
android:textColor="#FFFFFF"
android:textColorHint="#DDDDDD" />
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="5sp"
android:layout_alignParentBottom="true"
android:background="#EC9D21" />
</RelativeLayout>
的问题是,该按钮在RelativeLayout
就好了中心,但我EditText
对齐布局的顶部。有什么我失踪的?先谢谢你。
编辑在上面,我更新了我的XML。我将其设置为我的操作栏的自定义视图。但这应该没有什么不同,因为按钮没有问题对齐垂直居中。感谢名单
编辑的EditText应该对准中心垂直
这些类型的问题,它通常更容易,如果您发布完整的XML。然后我们可以在我们的编辑器中复制/粘贴以查看结果。另外,总有另一个'View'遮蔽事物的可能性。 – codeMagic
在RelativeLayout下面的属性是什么?另外,你可以发布你想要它的样子吗?我认为你有一些不必要的嵌套... – codeMagic
你尝试过'android:layout_gravity'吗? – t0mm13b