在我的RelativeLayout
中,我有一张大的背景图片,是海洋景色(1870px
x 756px
在drawable-xxhdpi
中),我将其居中显示在所有设备上:
<ImageView
android:src="@drawable/bg_image"
android:scaleType = "centerCrop"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ImageView>
除此之外,我想再放一张船的图片(500px
x 300px
,也在drawable-xxhdpi
中),水平居中,但应距离屏幕顶部230px
以在地平线上。
<ImageView
android:src="@drawable/another_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="230px"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
我的结果不正确,而且安卓系统提示我不能使用px
作为边距的单位。
结果:设备1(在地平线上进行了调整)
更小的设备2(未在地平线上进行调整):
有什么建议吗?