Android 安卓按钮位于图像下方
我对按钮和图像视图有一些问题。 我在布局xml中有类似的内容:Android 安卓按钮位于图像下方,android,button,imageview,Android,Button,Imageview,我对按钮和图像视图有一些问题。 我在布局xml中有类似的内容: <Button android:id="@+id/startGame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pressit" android:textSize="30dp" an
<Button
android:id="@+id/startGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pressit"
android:textSize="30dp"
android:paddingBottom="16dp"
android:background="@drawable/button_running_gradient"
android:gravity="bottom|center"
android:layout_alignTop="@+id/relativeLayout" />
<ImageView
android:id="@+id/img_How_To_Play"
android:src="@drawable/how_to_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:adjustViewBounds="true" />
<RelativeLayout
android:id="@+id/relativeLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainGame">
...
...
在一部手机上(等式sony xperia J),当应用程序启动时,按钮位于图像和相对位置下方,可以,但在另一部手机上(等式LG G2),按钮位于图像和布局上方。
我想要所有手机的第一选择。我如何才能做到这一点?
<RelativeLayout
android:id="@+id/relativeLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainGame">
<Button
android:id="@+id/startGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dfjvb"
android:textSize="30dp"
android:paddingBottom="16dp"
android:gravity="bottom|center"
android:layout_Above="@+id/img_How_To_Play" />
<ImageView
android:id="@+id/img_How_To_Play"
android:src="@drawable/photo243"
android:layout_below="@+id/startGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:adjustViewBounds="true" />
</RelativeLayout>
显示您的完整布局android:layout_alignTop=“@+id/relativeLayout”
删除+
您不应该只发布代码,请为OP解释您的代码正确性的确切原因…请查看OP,它更好,因为我在所有相同大小的设备中使用相对的,它的外观相同。