开发者

Disabling layer under SlidingDrawer in Android

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.


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);
    }
};


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜