【发布时间】:2013-09-05 21:35:38
【问题描述】:
我目前正在尝试将一些 LinearLayouts(然后填充一些图像)放置在屏幕上的绝对位置上。目前,LinearLayouts 与父 RelativeLayout 的左上角对齐,然后使用边距定位。这适用于所有子 LinearLayouts,除了列表中的第一个。在这种情况下,设置一些边距(例如左边距为 25dp)不会显示任何效果。我希望有人遇到同样的问题并可以提供一些指导。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_page"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/ll_first" android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="25dp" android:layout_marginTop="20dp"></LinearLayout>
<LinearLayout android:id="@+id/ll_second" android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="175dp" android:layout_marginTop="30dp"></LinearLayout>
<LinearLayout android:id="@+id/ll_third" android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="40dp" android:layout_marginTop="140dp"></LinearLayout>
</RelativeLayout>
【问题讨论】:
-
布局叠加在一起。甚至第一个放在你期望的地方,只是第二个和第三个会在第一个上面绘制,你放在那里的任何东西都会被过度绘制。最好将它们一个接一个地放置。
-
在下面查看我的评论 .. 不幸的是,这并没有解决问题:/
标签: android android-linearlayout android-relativelayout margins