@@ -720,13 +720,7 @@ export class View extends ViewCommon {
720720 }
721721
722722 [ androidElevationProperty . getDefault ] ( ) : number {
723- if ( sdkVersion ( ) < 21 ) {
724- return 0 ;
725- }
726-
727- // NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button)
728- // nativeView.getElevation() returns 0 at the time of the getDefault() query
729- return layout . toDeviceIndependentPixels ( ( < any > this . nativeViewProtected ) . getElevation ( ) ) ;
723+ return this . getDefaultElevation ( ) ;
730724 }
731725 [ androidElevationProperty . setNative ] ( value : number ) {
732726 if ( sdkVersion ( ) < 21 ) {
@@ -737,7 +731,7 @@ export class View extends ViewCommon {
737731 }
738732
739733 [ androidDynamicElevationOffsetProperty . getDefault ] ( ) : number {
740- return 0 ;
734+ return this . getDefaultDynamicElevationOffset ( ) ;
741735 }
742736 [ androidDynamicElevationOffsetProperty . setNative ] ( value : number ) {
743737 if ( sdkVersion ( ) < 21 ) {
@@ -747,16 +741,42 @@ export class View extends ViewCommon {
747741 this . refreshStateListAnimator ( ) ;
748742 }
749743
744+ protected getDefaultElevation ( ) : number {
745+ if ( sdkVersion ( ) < 21 ) {
746+ return 0 ;
747+ }
748+
749+ // NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button)
750+ // nativeView.getElevation() returns 0 at the time of the getDefault() query
751+ return layout . toDeviceIndependentPixels ( ( < any > this . nativeViewProtected ) . getElevation ( ) ) ;
752+ }
753+
754+ protected getDefaultDynamicElevationOffset ( ) {
755+ // NOTE: overriden in Button implementation
756+ return 0 ;
757+ }
758+
750759 private refreshStateListAnimator ( ) {
751760 const nativeView : any = this . nativeViewProtected ;
752761
753762 const ObjectAnimator = android . animation . ObjectAnimator ;
754763 const AnimatorSet = android . animation . AnimatorSet ;
755764
756765 const duration = nativeView . getContext ( ) . getResources ( ) . getInteger ( shortAnimTime ) / 2 ;
757- const elevation = layout . toDevicePixels ( this . androidElevation || 0 ) ;
766+
767+ let elevation = this . androidElevation ;
768+ if ( typeof elevation === "undefined" || elevation === null ) {
769+ elevation = this . getDefaultElevation ( ) ;
770+ }
771+ elevation = layout . toDevicePixels ( elevation ) ;
772+
758773 const z = layout . toDevicePixels ( 0 ) ;
759- const pressedZ = layout . toDevicePixels ( this . androidDynamicElevationOffset || 0 ) ;
774+
775+ let pressedZ = this . androidDynamicElevationOffset ;
776+ if ( typeof pressedZ === "undefined" || pressedZ === null ) {
777+ pressedZ = this . getDefaultDynamicElevationOffset ( ) ;
778+ }
779+ pressedZ = layout . toDevicePixels ( pressedZ ) ;
760780
761781 const pressedSet = new AnimatorSet ( ) ;
762782 pressedSet . playTogether ( java . util . Arrays . asList ( [
0 commit comments