2013-07-11 84 views
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> 

回答

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的寬度和高度或向它添加一些視圖。

0

確保藍色邊框首次添加在RelativeLayout的,無論是先加入頂部被渲染的圖像。

Z-index in android?

+0

那麼我該怎麼做呢?你看過這幅畫嗎? –

0

你給重力頂到的LinearLayout。所以它高於相對佈局。兩種佈局均使用android:id。第二個佈局必須低於第一個佈局。因此,使用下面的佈局屬性。

0

您看不到LinearLayout,因爲它的寬度和高度設置爲wrap_content,並且沒有內容。

0

brillenheini有答案。如果你想看到邊框,給它一些高度(例如20dp),導致沒有內容的包裝內容將沒有任何高度。