【发布时间】:2015-06-16 13:05:40
【问题描述】:
我有一个带有背景图片的RelativeLayout。在其中,我有另一个 RelativeLayout 带有背景颜色。我希望第二个 RelativeLayout 位于第一个的中间,但根据屏幕尺寸,它的比例尺是错误的。
代码如下:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<RelativeLayout
android:id="@+id/cellphone"
android:layout_marginLeft="80dp"
android:layout_marginBottom="120dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@drawable/cellphone">
<RelativeLayout
android:id="@+id/cellphone_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:background="#e34579">
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
大屏设备截图:
相同代码的屏幕截图,但是是小屏幕设备:
如您所见,黄色边框不应该是可见的。
我该如何解决?
P.S.:我有各种尺寸的背景图片 (cellphone.png)(从 drawable-ldpi 到 drawable-xxxhdpi)。
编辑:
xxhdpi 中的 cellphone.png 图像:
【问题讨论】:
-
你能提供具体的图片吗?
-
请出示手机.png
-
@RishiPaul,这是图片。
标签: android xml android-layout android-relativelayout