I have a problem with overlapping views in android appication
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_alignPar开发者_StackOverflow社区entTop="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>"
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.
精彩评论