gowong / material-sheet-fab

Android library that provides the floating action button to sheet transition from Google's Material Design.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SHEET POSITION CENTER -- NOT TO RIGHTMOST CORNER

madibalive opened this issue · comments

Hi, it doesn't to allow flexible positioning , is there to override it , so instead to enlarging in the leftmost corner it on the center above the fab(which is also position at the center)

Looking the source code it seem this is the method to override
setFabAnchor

Hi,
It sounds like you're looking to center the FAB and have the sheet open directly above it. This isn't supported since it's not a pattern outlined in the material design guidelines.

If you'd like to add support for this yourself, a good place to start would be MaterialSheetAnimation.alignSheetWithFab()

thanks for the reply, i spent the last hours the last two hours trying to get it in effect ,
the instance member sheet in the alignSheetWithFab is private so extending the class seem not do anything

                **// setting the sheet.setX(fab.coord[0] to the x cordinate of the fab** 

        if (rightDiff != 0) {  **// and removing this block of code should fix it i think**

            float sheetX = sheet.getX();
            // Align the right side of the sheet with the right side of the FAB if
            // doing so would not move the sheet off the screen
            if (rightDiff <= sheetX) {
                sheet.setX(sheetX - rightDiff - sheetLayoutParams.rightMargin);
                revealXDirection = RevealXDirection.LEFT;
            }
            // Otherwise, align the left side of the sheet with the left side of the FAB
            else if (leftDiff != 0 && leftDiff <= sheetX) {
                sheet.setX(sheetX - leftDiff + sheetLayoutParams.leftMargin);
                revealXDirection = RevealXDirection.RIGHT;
            }
        }

posted this stack overflow -- stackoverflow

sheet is a view that your app passes in so you could just keep a reference to it in your subclass of MaterialSheetAnimation