Pergunta

My top border wont show up, its getting put behind the other layout, how can I make it come up?

this is the image of what i need since i cant post images yet 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>
Foi útil?

Solução

<?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>

Setup width and height of LinearLayout or add some views to it.

Outras dicas

Make sure the blue border is added first in the RelativeLayout, whatever is added first gets rendered on top.

Z-index in android?

You give the gravity top to the linearlayout. So it come above of relative layout. Use android:id for both layouts . And second layout must be below first layout. So use below property of layout.

You don't see the LinearLayout because it has width and height set to wrap_content and there is no content.

brillenheini has the answer. If you want to see the border, give it some height (e.g 20dp) cause wrap content without a content won't have any height.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top