Android 运行时图像按钮的位置会发生变化

Android 运行时图像按钮的位置会发生变化,android,android-layout,Android,Android Layout,这是我的XML文件,用于在屏幕上放置5个按钮。当我在Android studio上放置按钮时,它看起来不错,但当我在一个小屏幕手机上调试时,元素的位置不正确,图像按钮相互重叠 <ImageButton android:layout_width="wrap_content" android:adjustViewBounds="true" android:layout_height="wrap_content" android:id="@+id/imageBut

这是我的XML文件,用于在屏幕上放置5个按钮。当我在Android studio上放置按钮时,它看起来不错,但当我在一个小屏幕手机上调试时,元素的位置不正确,图像按钮相互重叠

<ImageButton
    android:layout_width="wrap_content"
    android:adjustViewBounds="true"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton1"
    android:src="@drawable/btn_01"
    android:layout_marginLeft="65dp"
    android:layout_marginTop="11dp"
    android:layout_below="@+id/txtReceive" />

<ImageButton
    android:layout_width="wrap_content"
    android:adjustViewBounds="true"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton2"
    android:src="@drawable/btn_02"
    android:layout_marginLeft="52dp"
    android:layout_marginTop="50dp"
    android:layout_below="@+id/txtReceive"/>

<ImageButton
    android:layout_width="wrap_content"
    android:adjustViewBounds="true"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton3"
    android:src="@drawable/btn_03"
    android:layout_marginLeft="52dp"
    android:layout_marginTop="92dp"
    android:layout_below="@+id/txtReceive" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:id="@+id/imageButton4"
    android:src="@drawable/btn_04"
    android:layout_marginLeft="62dp"
    android:layout_marginTop="135dp"
    android:layout_below="@+id/txtReceive" />

<ImageView
    android:layout_width="wrap_content"
    android:adjustViewBounds="true"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton5"
    android:src="@drawable/send_btn"
    android:layout_marginLeft="165dp"
    android:layout_marginTop="55dp"
    android:layout_below="@+id/txtReceive" />


正如Nikunj Sakhrelia所指出的,图像按钮在不同的屏幕尺寸上可能呈现不同的效果,在设置按钮的边距时会遇到麻烦。最好使用方向设置为垂直的LinearLayout,以确保图像按钮显示在彼此下方,仅使用边距创建空白

请告诉我您使用什么类型的布局?它是相对布局。请尝试将下面的布局更改为其顶部图像按钮,而不是将margintop设置为所有imageButton,因为顶部边距值可能会在不同的屏幕分辨率下产生不同的结果。很抱歉,是的,这是相对布局。好的,我将尝试将下面的布局更改为顶部的图像按钮问题是,我需要每个按钮在某个位置彼此相邻,以便它们形成一个圆圈。每个按钮都是圆形的。。我会尝试做一些网格结构,这样你就可以把每个按钮放在一个固定的地方。看看gridlayout。我对gridlayout有点怀疑。想象一个新月形。4个按钮组成新月形,将其水平分为4个相等的部分。现在在新月形的凹面区域,一个圆形按钮将连接起来,形成两个相互重叠的圆圈。因此,总共有5个按钮,这在网格布局中是可以实现的吗。当我插入按钮时,网格空间扩大,我无法在附近放置其他按钮