質問

I am currently implementing the SlidingDrawer. However my issue is that when I open the SlidingDrawer, it simply doesn't open fully as it only opens to the bottom of the ListView that I have and that currently means I can barely see what is inside the SlidingDrawer. I want the SlidingDrawer to slide over the top of the ListView, at least to half way up the screen. How is this possible? Currently it only opens to the space it is given and I would like it to forget there is another view above it effectively. My current code is displayed below:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/linearLayout"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
     android:padding="8dp"
     android:background="@color/background_colour" >

 <LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:background="@drawable/white_corners" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/Item"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/addItem"
            android:layout_alignParentTop="true"
            android:ems="10"
            android:textColor="@android:color/black"
            android:hint="@string/hint"
            android:textColorHint="@android:color/black" >
            <requestFocus />
        </EditText>

        <ImageButton
            android:id="@+id/addItem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@android:drawable/ic_menu_add"
            android:layout_toRightOf="@+id/Item"
            android:contentDescription="@string/hint" />

    </RelativeLayout>

    <ListView
        android:id="@+id/android:list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="8dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:dividerHeight="8dp"
        android:scrollbarStyle="outsideOverlay" />      

</LinearLayout>

<SlidingDrawer
   android:id="@+id/slidingDrawer"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignParentBottom="true"
   android:content="@+id/drawerContentLayout"
   android:handle="@+id/slideButton"
   android:orientation="vertical" >

   <Button
       android:id="@+id/slideButton"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="^" />

   <LinearLayout
       android:id="@+id/drawerContentLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World" />
   </LinearLayout>       
</SlidingDrawer>

</LinearLayout>

Thanks in advance. Your help is greatly appreciated!

役に立ちましたか?

解決

Make your root a RelativeLayout, and have both the child Linear Layout and the SlidingDrawer fill_parent for height.

A LinearLayout can't have two views that overlap.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top