diff --git a/apps/animations/opacity.ts b/apps/animations/opacity.ts index ed8cd14f8..dceecd0fd 100644 --- a/apps/animations/opacity.ts +++ b/apps/animations/opacity.ts @@ -25,8 +25,11 @@ export function pageLoaded(args: observable.EventData) { export function onSetOpacity(args: observable.EventData) { var newOpacity = opacitySlider.value / 100; - container._eachChildView((childView: view.View) => { - childView.opacity = newOpacity; + container._eachChildView((view: view.View) => { + if (view.android) { + view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null); + } + view.opacity = newOpacity; return true; }); } @@ -35,9 +38,12 @@ var animationSet: animationModule.Animation; export function onAnimateOpacity(args: observable.EventData) { var newOpacity = opacitySlider.value / 100; var animationDefinitions = new Array(); - container._eachChildView((childView: view.View) => { + container._eachChildView((view: view.View) => { + if (view.android) { + view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null); + } animationDefinitions.push({ - target: childView, + target: view, opacity: newOpacity, duration: 5000 }); diff --git a/ui/animation/animation.android.ts b/ui/animation/animation.android.ts index be762396d..bcb0702f2 100644 --- a/ui/animation/animation.android.ts +++ b/ui/animation/animation.android.ts @@ -159,18 +159,11 @@ export class Animation extends common.Animation implements definition.Animation case common.Properties.opacity: originalValue1 = nativeView.getAlpha(); - nativeArray = java.lang.reflect.Array.newInstance(floatType, 2); - nativeArray[0] = originalValue1; - nativeArray[1] = propertyAnimation.value; - animator = android.animation.ValueAnimator.ofFloat(nativeArray); - animator.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener({ - onAnimationUpdate(animator: android.animation.ValueAnimator) { - propertyAnimation.target.opacity = (animator.getAnimatedValue()).floatValue(); - } - })); - propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value; })); - propertyResetCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = originalValue1; })); - animators.push(animator); + nativeArray = java.lang.reflect.Array.newInstance(floatType, 1); + nativeArray[0] = propertyAnimation.value; + propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value })); + propertyResetCallbacks.push(checkAnimation(() => { nativeView.setAlpha(originalValue1); })); + animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray)); break; case common.Properties.backgroundColor: diff --git a/ui/styling/stylers.android.ts b/ui/styling/stylers.android.ts index 956ac997e..4405d5492 100644 --- a/ui/styling/stylers.android.ts +++ b/ui/styling/stylers.android.ts @@ -341,25 +341,6 @@ export class ImageStyler implements definition.stylers.Styler { onBackgroundOrBorderPropertyChanged(view); } - //Opacity methods - private static setOpacityProperty(view: view.View, newValue: any) { - ImageStyler._setOpacity(view, newValue); - } - - private static resetOpacityProperty(view: view.View, nativeValue: any) { - ImageStyler._setOpacity(view, 1.0); - } - - private static _setOpacity(view: view.View, value: any) { - let opacity = float(value); - let nativeView = view._nativeView; - nativeView.setAlpha(opacity); - let background = nativeView.getBackground(); - if (background) { - background.setAlpha(opacity); - } - } - public static registerHandlers() { // Use the same handler for all background/border properties // Note: There is no default value getter - the default value is handled in onBackgroundOrBorderPropertyChanged @@ -371,10 +352,6 @@ export class ImageStyler implements definition.stylers.Styler { style.registerHandler(style.borderWidthProperty, new stylersCommon.StylePropertyChangedHandler( ImageStyler.setBorderWidthProperty, ImageStyler.resetBorderWidthProperty), "Image"); - - style.registerHandler(style.opacityProperty, new stylersCommon.StylePropertyChangedHandler( - ImageStyler.setOpacityProperty, - ImageStyler.resetOpacityProperty), "Image"); } }