1

I've found a few questions on this topic and i've tried the solutions, but I can't seem to get it right. I have a TableLayout as the first child in a RelativeLayout and a SlidingDrawer as the second child. The slide works fine, but clicking on the drawer when it's open goes through to the items under the drawer.

I've tried adding an ontouch listener with a "return true" to the opening of the slider, but all that seems to do is not allow me to open the drawer. Also, anything that "would" be covered by the drawer if it was open, is unclickable.

If I change the "return true" to a

if (slidingDrawer.isOpened()) return true; else return false;

this gives me a couple of problems. While the drawer opens and i cannot click through to the lower layer, I also cannot click anything on the drawer or click the handle to close the drawer.

I'm not sure what I'm missing. I'd appreciate any help.

Metallicraft
  • 2,211
  • 5
  • 31
  • 52

3 Answers3

3

I finally got around this by doing the following type of thing:

//sliderdrawer close
private OnDrawerCloseListener onClick_DrawerClosed = new OnDrawerCloseListener() {
    @Override
    public void onDrawerClosed() {
        _slideDrawer.setClickable(false);
    }
};

//sliderdrawer open
private OnDrawerOpenListener onClick_DrawerOpened = new OnDrawerOpenListener() {
    @Override
    public void onDrawerOpened() {
        _slideDrawer.setClickable(true);
    }
};
Metallicraft
  • 2,211
  • 5
  • 31
  • 52
3

Try setting android:clickable="true" on the sliding drawer content component rather than toggling it on the parent drawer component. Works for me and doesn't require code to listen for the state change.

  • This works, but if your content is included from a separate xml file with tags, you have to put the 'android:clickable="true"' inside the layout of the child layout file. [See this comment:](http://stackoverflow.com/questions/5393314/android-slidingdrawer-doesnt-disable-buttons-under-the-drawer/7626797#7626797) – RichardB Oct 02 '11 at 14:03
1

Setting the clickable completely removes any pass through to the window behind, whereas the procedural method, will allow the item below to see clicks once the drawer is closed.

Nicked
  • 11
  • 1