0

我的顶部边框不会出现,它被放在另一个布局后面,我怎样才能让它出现?

这是我需要的图像,因为我还不能发布图像 http://tinypic.com/r/33nhk4k/5

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/AliceBlue" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@color/Blue"
    android:gravity="top" >

</LinearLayout>

</RelativeLayout>
4

5 回答 5

0

确保首先在 RelativeLayout 中添加蓝色边框,首先添加的内容都会呈现在顶部。

android中的Z索引?

于 2013-07-11T16:54:44.920 回答
0

您将重力顶部赋予线性布局。所以它高于相对布局。对两种布局都使用 android:id 。第二个布局必须低于第一个布局。所以使用下面的布局属性。

于 2013-07-11T17:33:33.563 回答
0

您看不到 ,LinearLayout因为它设置了宽度和高度wrap_content并且没有内容。

于 2013-07-11T17:51:17.833 回答
0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/AliceBlue" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@color/Blue"
    android:gravity="top" >

</LinearLayout>

</RelativeLayout>

设置 LinearLayout 的宽度和高度或添加一些视图。

于 2013-07-11T18:37:01.450 回答
0

布里伦海尼给出了答案。如果您想查看边框,请给它一些高度(例如 20dp),因为没有内容的包装内容将没有任何高度。

于 2013-07-11T18:37:23.543 回答