Facebook lide slideout menu (Not using that library)

后端 未结 1 428
死守一世寂寞
死守一世寂寞 2020-12-14 13:43

I want to have facebook like menu in my application. There are many threads on this and all of them suggest to use a library which actually just takes a screenshot of the sc

相关标签:
1条回答
  • 2020-12-14 13:56

    Finally somehow I could do it. Here's the code used when I click on the menu button on the left top corner:

    @Override
    public void onClick(View v) {
    rootLayoutParams = new LayoutParams(rightLayout.getWidth(),
        rightLayout.getHeight());
    
    if (lhsMenu.getVisibility() == View.GONE) {
        lhsMenu.setVisibility(View.VISIBLE);
        Animation slideRight = setRightSlidingAnimation();
        rightLayout.setAnimation(slideRight);
        lhsMenu.setAnimation(slideRight);
    } else {
        Animation slideLeft = setLeftSlidingAnimation();
        rightLayout.setAnimation(slideLeft);
        lhsMenu.setAnimation(slideLeft);
        lhsMenu.setVisibility(View.GONE);
        }
    }
    

    Update: Also set margin to left and right (if needed) of rightLayout so that the rightLayout will not shrink.

    _rightLayoutParams.setMargins(width, 0, -width, 0);

    where width = 200 in my case.

    0 讨论(0)
提交回复
热议问题