@@ -54,31 +54,28 @@ export class SnackBar extends SnackBarBase {
54
54
}
55
55
const page = attachView instanceof Page ? attachView : attachView . page ;
56
56
let nView = ( page . nativeViewProtected as android . view . View ) . getParent ( ) ;
57
- if ( page . hasActionBar ) {
58
- nView = nView . getParent ( ) ;
59
- }
60
57
let nCoordinatorLayout : androidx . coordinatorlayout . widget . CoordinatorLayout = ( page as any ) . nCoordinatorLayout ;
61
58
if ( ! nCoordinatorLayout && ! ( nView instanceof androidx . coordinatorlayout . widget . CoordinatorLayout ) && nView instanceof android . view . ViewGroup ) {
62
59
nCoordinatorLayout = new androidx . coordinatorlayout . widget . CoordinatorLayout ( attachView . _context ) ;
63
60
64
61
if ( options . view ) {
65
62
const nAttachedView = options . view . nativeViewProtected as android . view . View ;
66
63
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 ) ;
74
69
} else {
75
70
( nView as any ) . addView ( nCoordinatorLayout , new android . view . ViewGroup . LayoutParams ( android . view . ViewGroup . LayoutParams . MATCH_PARENT , android . view . ViewGroup . LayoutParams . MATCH_PARENT ) ) ;
76
71
}
77
72
78
73
nView = nCoordinatorLayout ;
79
74
}
80
75
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
+ }
82
79
// this._snackbar.setText(options.message);
83
80
// this._snackbar.setDuration(options.hideDelay);
84
81
0 commit comments