Android RelativeLayout项目在编辑器和设备上的不同位置

Android RelativeLayout项目在编辑器和设备上的不同位置,android,android-layout,android-button,android-relativelayout,Android,Android Layout,Android Button,Android Relativelayout,我正试图在RelativeLayout中创建页脚,其中包含3个项目-一个图像视图,一个文本视图和一个按钮。我设法将ImageView定位在布局的左侧,并将TextView靠近ImageView定位在左侧。但,我无法正确设置布局右侧的按钮位置。编辑器和设备中的位置不同(当我测试它时)。当我在编辑器中以我想要的方式定位所有内容时,在设备上运行之后,它看起来就不一样了按钮”将离开屏幕 例如,这是我在编辑器中看到的,也是我在设备上看到的。若我在编辑器中将按钮移动到它应该在的位置,那个么它将在设备上离开屏

我正试图在
RelativeLayout
中创建页脚,其中包含3个项目-一个
图像视图
,一个
文本视图
和一个
按钮
。我设法将
ImageView
定位在布局的左侧,并将
TextView
靠近
ImageView
定位在左侧。但,我无法正确设置布局右侧的按钮位置。编辑器和设备中的位置不同(当我测试它时)。当我在编辑器中以我想要的方式定位所有内容时,在设备上运行之后,它看起来就不一样了<应位于布局右侧的“代码>按钮”将离开屏幕

例如,这是我在编辑器中看到的,也是我在设备上看到的。若我在编辑器中将按钮移动到它应该在的位置,那个么它将在设备上离开屏幕

我也尝试过使用
线性布局
重力
布局_重力
重量
,以及不同的填充和边距组合,但我就是无法让它工作,我不明白问题出在哪里

这是我的xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:padding="4dp">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background" />

    <ImageView
        android:layout_width="55dp"
        android:layout_height="55dp"
        android:paddingBottom="3dp"
        android:paddingTop="3dp"
        android:src="@mipmap/help" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="60dp"
        android:paddingTop="10dp"
        android:text="help"
        android:textColor="@color/mainWhite" />

    <Button
        android:id="@+id/helpButton"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="330dp"
        android:layout_marginTop="3dp"
        android:background="@mipmap/Continue" />
</RelativeLayout>


谢谢。

只需在右侧按钮中使用
android:layout\u alignParentEnd=“true”

    <Button
    android:id="@+id/helpButton"
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:layout_marginTop="3dp"
    android:layout_alignParentEnd="true"
    android:background="@android:drawable/ic_input_add"/>

您的完整布局应该如下所示。您需要正确使用
layout\u alignParentLeft
layout\u alignParentRight

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_margin="5dp"
    android:background="@drawable/background"
    android:padding="4dp">

    <ImageView
        android:id="@+id/question_icon"
        android:layout_width="55dp"
        android:layout_height="55dp"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="8dp"
        android:padding="3dp"
        android:src="@mipmap/help" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="16dp"
        android:layout_toRightOf="@+id/question_icon"
        android:text="Help"
        android:textColor="@android:color/white" />

    <Button
        android:id="@+id/helpButton"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_alignParentRight="true"
        android:layout_marginRight="8dp"
        android:background="@mipmap/Continue" />
</RelativeLayout>