0

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>
Ranco
  • 893
  • 2
  • 13
  • 43
Jordin Youssef
  • 1,147
  • 2
  • 7
  • 4

5 Answers5

0

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

Z-index in android?

Community
  • 1
  • 1
upopple
  • 73
  • 1
  • 7
0

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.

Rahul
  • 10,457
  • 4
  • 35
  • 55
0

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

brillenheini
  • 5,413
  • 3
  • 23
  • 20
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>

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

Korniltsev Anatoly
  • 3,676
  • 2
  • 26
  • 37
0

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.

Hugo
  • 170
  • 1
  • 11