tags:

views:

34

answers:

1

I have a navbar included in a linearlayout with another relativelayout as below. This relative layout forms the whole screen while the navbar is on top. I have added a button in the navbar and a listview which becomesvisible when the button is clicked. The problem is: when the button is clicked I am expecting the list to be displayed on top of the below screen contents while it is actually pushing down the contents of the screen and is not overlapping. I have tried relative layouts and framelayouts as in all the examples but with no luck. Please help:.

<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_alignParentTop="true" android:background="@drawable/xxx">

<include android:id="@+id/navbarx" layout="@layout/navbar" /><<<-- has the button and the listview for it.
<RelativeLayout android:layout_width="fill_parent"
android:layout_weight="1" android:layout_marginTop="10dp"
android:layout_height="0dp" android:layout_gravity="top|fill">

<ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="#00ffffff" android:layout_marginLeft="14dp"
android:layout_marginRight="5dp" android:layout_marginTop="10dp"
android:layout_marginBottom="40dp" android:drawSelectorOnTop="true"
android:divider="#00ffffff" android:listSelector="@drawable/yyy"
android:scrollbarThumbVertical="@drawable/vertical_slider"
android:headerDividersEnabled="false" android:layout_alignParentTop="true" android:layout_alignWithParentIfMissing="true"/>

</RelativeLayout>

</LinearLayout>"
A: 

Within a LinearLayout, things will never overlap. If you want the included navbar to appear on top of the relative layout, then you need to either put them in a relative layout, or a frame layout. For example:

<FrameLayout . . . >
  <RelativeLayout . . .">
    <ListView android:id="@android:id/list" . . ./>
  </RelativeLayout>

  <include android:id="@+id/navbarx" layout="@layout/navbar" />
</FrameLayout>

This will cause the included layout to appaer on top of the relativeLayout with ListView.

Mayra
Thanks for the quick reponse. I did think about this. But had a concern: wont this make the navbar completely overlap on the relativelayout always... what i am expecting is that the list in the navbar should be the only one overlapping the below relativelayout and only upon button click. Thanks again for ur suggestion
kash
Yes, thats probably true. You have a few options, you can give the relativeLayout with the listview some top padding so that it is pushed down, or you can split out the navbar from the listiew in your included layout so that you can put the navbar itself outside of the frameLayout.
Mayra
Thanks will try them out!
kash
I see that the listview contents in the relativelayout are completely disappearing when I try these.. Is it because of the properties? What am I missing here?
kash
thanks a lot, it was the properties and its working fine now!!
kash
Great! If this answered your question, please mark it as the correct answer by checking the checkbox next to the answer.
Mayra