Example usage for android.view.animation Transformation setAlpha

List of usage examples for android.view.animation Transformation setAlpha

Introduction

In this page you can find the example usage for android.view.animation Transformation setAlpha.

Prototype

public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) 

Source Link

Document

Sets the degree of transparency

Usage

From source file:com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy.java

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();/*from  w  w  w  .j  a va  2 s .c  o  m*/
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}

From source file:android.widget.Gallery.java

@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {

    t.clear();//from   w  w w.j a v a 2s .c  o m
    t.setAlpha(child == mSelectedChild ? 1.0f : mUnselectedAlpha);

    return true;
}

From source file:com.inmobi.nativead.sample.photopages.CustomViewPager.java

@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
    // We can cast here because CustomPagerAdapter only creates wrappers.
    CustomViewPagerItemWrapper item = (CustomViewPagerItemWrapper) child;

    // Since Jelly Bean children won't get invalidated automatically,
    // needs to be added for the smooth coverflow animation
    if (android.os.Build.VERSION.SDK_INT >= 16) {
        item.invalidate();/*from  w ww  .  ja  v a2s.  c o  m*/
    }

    final int coverFlowWidth = this.getWidth();
    final int coverFlowCenter = coverFlowWidth / 2;
    final int childWidth = item.getWidth();
    final int childHeight = item.getHeight();
    final int childCenter = item.getLeft() + childWidth / 2;

    // Use coverflow width when its defined as automatic.
    final int actionDistance = (this.actionDistance == ACTION_DISTANCE_AUTO)
            ? (int) ((coverFlowWidth + childWidth) / 2.0f)
            : this.actionDistance;

    // Calculate the abstract amount for all effects.
    final float effectsAmount = Math.min(1.0f,
            Math.max(-1.0f, (1.0f / actionDistance) * (childCenter - coverFlowCenter)));

    // Clear previous transformations and set transformation type (matrix + alpha).
    t.clear();
    t.setTransformationType(Transformation.TYPE_BOTH);

    // Alpha
    if (this.unselectedAlpha != 1) {
        final float alphaAmount = (this.unselectedAlpha - 1) * Math.abs(effectsAmount) + 1;
        t.setAlpha(alphaAmount);
    }

    // Saturation
    if (this.unselectedSaturation != 1) {
        // Pass over saturation to the wrapper.
        final float saturationAmount = (this.unselectedSaturation - 1) * Math.abs(effectsAmount) + 1;
        item.setSaturation(saturationAmount);
    }

    final Matrix imageMatrix = t.getMatrix();

    // Apply rotation.
    if (this.maxRotation != 0) {
        final int rotationAngle = (int) (-effectsAmount * this.maxRotation);
        this.transformationCamera.save();
        this.transformationCamera.rotateY(rotationAngle);
        this.transformationCamera.getMatrix(imageMatrix);
        this.transformationCamera.restore();
    }

    // Zoom.
    if (this.unselectedScale != 1) {
        final float zoomAmount = (this.unselectedScale - 1) * Math.abs(effectsAmount) + 1;
        // Calculate the scale anchor (y anchor can be altered)
        final float translateX = childWidth / 2.0f;
        final float translateY = childHeight * this.scaleDownGravity;
        imageMatrix.preTranslate(-translateX, -translateY);
        imageMatrix.postScale(zoomAmount, zoomAmount);
        imageMatrix.postTranslate(translateX, translateY);
    }

    return true;
}