Android: SlidingDrawer disappears under SurfaceView

Posted by ykrasik on Stack Overflow See other posts from Stack Overflow or by ykrasik
Published on 2011-01-07T20:09:44Z Indexed on 2011/01/08 5:54 UTC
Read the original article Hit count: 493

Filed under:
|

Hi,

I'm trying to create a SlidingDrawer with LinearLayout content over a FrameLayout.

At first it all seems fine, I get my SlidingDrawer's handle at the bottom of the screen. But then, if I start dragging the handle up and the content starts showing, it gets clipped by the border rectangle of the handle. If I drag the handle all the way up the entire content eventually gets shown, however if I now drag the handle down, it will be clipped by the border rectangle of the content. Also, if the handle is all the way up, as soon as I start dragging it the whole content disappears.
I can still click on where the handle should be on the screen, drag it and the content would show, but I need to guess where the handle is.

What seems to be causing this is the fact that I have a SurfaceView in the xml file just before SlidingDrawer.
Removing the view from the xml solves this problem, however I need this view.

Here's the xml:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

    <!--  Removing this DrawView from here solves the problem -->
    <com.package.DrawView 
        android:id="@+id/main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />

    <SlidingDrawer  
        android:id="@+id/SlidingDrawer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:allowSingleTap="true"
        android:animateOnClick="true"
        android:handle="@+id/slideHandleButton"
        android:content="@+id/contentLayout" 
        android:padding="10dip">

        <Button
            android:id="@+id/slideHandleButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/sliding_button">
        </Button>

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

            <Button 
                android:id="@+id/clearButton" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Test">
            </Button>

        </LinearLayout>

    </SlidingDrawer>

</FrameLayout>   

Java:

package com.package;

import android.app.Activity;
import android.os.Bundle;

public class SlideTest extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
    }
}

package com.package;

import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceView;

public class DrawView extends SurfaceView
{
    public DrawView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
}

Edit: I just noticed that if DrawView extends View and not SurfaceView this problem goes away. However, I'm using a dedicated drawing thread and according to the documentation (and LunarLander example) when using a dedicated drawing thread, it should draw to a SurfaceView.

Any help would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about android

Related posts about slidingdrawer