Android ImageButton与另一个ImageButton重叠
我预览了这个布局 使用此代码:Android ImageButton与另一个ImageButton重叠,android,layout,Android,Layout,我预览了这个布局 使用此代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="50dp" android:background="@drawable/actionbar_background" android:gravity="center_vertical" andr
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/actionbar_background"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingRight="10dp" >
<ImageButton
android:id="@+action_bar_documentos/btn_menu"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:adjustViewBounds="true"
android:background="@drawable/list_selector_action_bar"
android:contentDescription="@string/app_name"
android:cropToPadding="false"
android:onClick="menu"
android:scaleType="center"
android:src="@drawable/menu" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+action_bar_documentos/btn_menu" >
<ImageButton
android:id="@+action_bar/btn_camera"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
android:layout_toRightOf="@+action_bar/btn_menu"
android:background="@drawable/list_selector_action_bar"
android:contentDescription="@string/app_name"
android:onClick="btnCamera"
android:scaleType="centerCrop"
android:src="@drawable/img_camera" />
<ImageButton
android:id="@+action_bar_documentos/btn_search"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+action_bar_documentos/btn_camera"
android:background="@drawable/list_selector_action_bar"
android:contentDescription="@string/app_name"
android:onClick="filtro"
android:paddingBottom="5dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="3dp"
android:scaleType="centerCrop"
android:src="@drawable/btn_filtro_top" />
</RelativeLayout>....
....
现在看起来不错。但当我运行我的应用程序时,布局变成:
屏幕大小有问题吗?或者问题出在我的xml代码上
谢谢,语法错误让您感到抱歉。您的
btn\u摄像头
不应该是toRightOf
btn\u菜单
,因为btn\u菜单
不在同一相对区域内。相反,btn\U摄像头
应该使用alignParentLeft=“true”
或者,您可以在嵌套的RelativeLayout内移动btn_camera
此外,正如@epsilondelta所评论的那样,您的
btn\u搜索
为btn\u摄像头的id引用了错误的名称空间
。有时,在关闭并重新打开xml文件之前,编辑器布局视图中不会捕捉到类似的错误。您的btn\u相机
不应该是toRightOf
btn\u菜单
,因为btn\u菜单
不在同一相对区域内。相反,btn\U摄像头
应该使用alignParentLeft=“true”
或者,您可以在嵌套的RelativeLayout内移动btn_camera
此外,正如@epsilondelta所评论的那样,您的
btn\u搜索
为btn\u摄像头的id引用了错误的名称空间
。有时,在关闭并重新打开xml文件之前,编辑器布局视图中不会捕捉到此类错误。在第二个ImageButton中,android:layout_-toRightOf属性是否应为“@+action_bar/btn_camera”?在第二个ImageButton中,android:layout_-toRightOf属性是否应为“@+action_bar/btn_camera”谢谢@Tenfour04我分心了。谢谢@Tenfour04我分心了。