【发布时间】:2013-10-25 19:24:27
【问题描述】:
我正在尝试将 2 个布局放在彼此之上,但它不起作用。有一个空间我不知道如何删除。
这是我的代码:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom|center"
android:weightSum="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="170dp"
android:layout_weight="0.5"
android:background="@drawable/column_white"
android:layout_gravity="bottom|center"
android:gravity="bottom"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="10sp"
android:layout_height="100sp"
android:background="@drawable/arrow_body"
android:layout_marginLeft="10sp"
></LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/arrow_shape"
android:layout_marginLeft="6sp"
></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_margin="25sp"
android:background="@drawable/column_blue"
android:gravity="center"
android:layout_weight="0.5" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40 000 "
android:textColor="#ffffff"
android:textSize="25sp" />
</LinearLayout>
</LinearLayout>
RelativeLayout:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="170dp"
android:background="@drawable/column_white"
android:gravity="bottom"
android:layout_alignBottom="@id/second_part"
android:orientation="vertical" >
<LinearLayout
android:layout_width="10sp"
android:layout_height="100sp"
android:layout_marginLeft="10sp"
android:background="@drawable/arrow_body" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6sp"
android:background="@drawable/arrow_shape" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/second_part"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_margin="25sp"
android:background="@drawable/column_blue"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40 000"
android:textColor="#ffffff"
android:textSize="25sp" />
</LinearLayout>
</RelativeLayout>
【问题讨论】:
-
使用相对布局作为根视图。
-
使用RelativeLayout或FrameLayout作为根
-
我也试过了,修改了我的代码
-
你能给我们看截图吗?
-
阅读我的评论。在您的相对布局中,您仍然有您的 margin:25sp 在第二个。