@@ -54,31 +54,28 @@ export class SnackBar extends SnackBarBase {
5454 }
5555 const page = attachView instanceof Page ? attachView : attachView . page ;
5656 let nView = ( page . nativeViewProtected as android . view . View ) . getParent ( ) ;
57- if ( page . hasActionBar ) {
58- nView = nView . getParent ( ) ;
59- }
6057 let nCoordinatorLayout : androidx . coordinatorlayout . widget . CoordinatorLayout = ( page as any ) . nCoordinatorLayout ;
6158 if ( ! nCoordinatorLayout && ! ( nView instanceof androidx . coordinatorlayout . widget . CoordinatorLayout ) && nView instanceof android . view . ViewGroup ) {
6259 nCoordinatorLayout = new androidx . coordinatorlayout . widget . CoordinatorLayout ( attachView . _context ) ;
6360
6461 if ( options . view ) {
6562 const nAttachedView = options . view . nativeViewProtected as android . view . View ;
6663 const params = new android . widget . FrameLayout . LayoutParams ( nAttachedView . getWidth ( ) , nAttachedView . getHeight ( ) ) ;
67- const myArray = Array . create ( 'int' , 2 ) ;
68- nView . getLocationOnScreen ( myArray ) ;
69- const otherArray = Array . create ( 'int' , 2 ) ;
70- options . view . nativeViewProtected . getLocationOnScreen ( otherArray ) ;
71-
72- params . topMargin = otherArray [ 1 ] - myArray [ 1 ] ;
73- ( nView as any ) . addView ( nCoordinatorLayout , params ) ;
64+ params . gravity = android . view . Gravity . BOTTOM ;
65+ const locationArray = Array . create ( 'int' , 2 ) ;
66+ options . view . nativeViewProtected . getLocationOnScreen ( locationArray ) ;
67+ params . bottomMargin = nView . getHeight ( ) - locationArray [ 1 ] - nAttachedView . getHeight ( ) ;
68+ nView . addView ( nCoordinatorLayout , params ) ;
7469 } else {
7570 ( nView as any ) . addView ( nCoordinatorLayout , new android . view . ViewGroup . LayoutParams ( android . view . ViewGroup . LayoutParams . MATCH_PARENT , android . view . ViewGroup . LayoutParams . MATCH_PARENT ) ) ;
7671 }
7772
7873 nView = nCoordinatorLayout ;
7974 }
8075 this . _snackbar = com . google . android . material . snackbar . Snackbar . make ( nView as any , options . message , options . hideDelay ) ;
81-
76+ if ( options . anchorView ) {
77+ this . _snackbar . setAnchorView ( options . anchorView . nativeViewProtected ) ;
78+ }
8279 // this._snackbar.setText(options.message);
8380 // this._snackbar.setDuration(options.hideDelay);
8481
0 commit comments