图像按钮未显示在不同设备上的相同位置,例如:具有 API 级别 =16

Image Buttons are not displaying on same position on different devices, eg : having API level =16

我在为不同设备在相同位置显示按钮(上一个 (@id/ib1) 、下一个 (@id/ib2))时遇到问题。 按钮略低于设备(摩托罗拉 Droid Razr 4.1.2 Api 级别 16)。 XML如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/firstLay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="@drawable/bckgrd"
    android:gravity="center">

    <LinearLayout
        android:id="@+id/layalif"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="10">

        <LinearLayout
            android:id="@+id/layalif1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="3.2"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/ivalif1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="40dp"
                android:layout_marginRight="40dp"
                android:src="@drawable/alifmadstatic" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/layalif2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="2.3">

            <ImageView

                android:id="@+id/ivalif2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layerType="none"
                android:scaleType="fitXY"
                android:src="@drawable/backgroundmove" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/layadd"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="4.5">


        </LinearLayout>


    </LinearLayout>

    <pro.photex.com.testpoint.drawalifmadaa
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layerType="software"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />


    <ImageButton
        android:layout_width="64dp"
        android:layout_height="48dp"
        android:scaleType="centerInside"
        android:id="@+id/ib1"
        android:layout_marginLeft="0dp"
        android:src="@drawable/previews"
        android:onClick="btnpreviousclick"
        android:background="@color/Transparent"
        android:layout_marginBottom="70dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ImageButton
        android:layout_width="64dp"
        android:layout_height="48dp"
        android:scaleType="centerInside"
        android:id="@+id/ib2"
        android:src="@drawable/next"
        android:background="@color/Transparent"
        android:onClick="btnnxtonclick"
        android:layout_alignTop="@+id/ib1"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>

这是输出图像 Api 级别 16(屏幕密度 1.5):

[

这是输出图像 Api 级别 21(屏幕密度 1.5):

添加

android:layout_alignBottom="@+id/layalif" 在你的两个 ImageButton

并删除

android:layout_marginBottom="70dp"