当前位置: 首页>>代码示例>>Java>>正文


Java View.getAlpha方法代码示例

本文整理汇总了Java中android.view.View.getAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java View.getAlpha方法的具体用法?Java View.getAlpha怎么用?Java View.getAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.getAlpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDraw

import android.view.View; //导入方法依赖的package包/类
/**
 * Overriding onDraw allows us to draw shadows behind every child of this container.
 * onDraw() is called to draw a layout's content before the children are drawn, so the
 * shadows will be drawn first, behind the children (which is what we want).
 */
@Override
protected void onDraw(Canvas canvas) {
    for (int i = 0; i < getChildCount(); ++i) {
        View child = getChildAt(i);
        if (child.getVisibility() != View.VISIBLE || child.getAlpha() == 0) {
            continue;
        }
        int depthFactor = (int) (80 * mShadowDepth);
        canvas.save();
        canvas.translate(child.getLeft() + depthFactor,
                child.getTop() + depthFactor);
        canvas.concat(child.getMatrix());
        tempShadowRectF.right = child.getWidth();
        tempShadowRectF.bottom = child.getHeight();
        canvas.drawBitmap(mShadowBitmap, sShadowRect, tempShadowRectF, mShadowPaint);
        canvas.restore();
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:ShadowLayout.java

示例2: prepare

import android.view.View; //导入方法依赖的package包/类
/** 初始化数据 */
private void prepare(CoordinatorLayout parent, View child, View dependency) {
    mDependStartX = (int) dependency.getX();
    mDependStartY = (int) dependency.getY();
    mDependStartWidth = dependency.getWidth();
    mDependStartHeight = dependency.getHeight();
    mStartX = (int) child.getX();
    mStartY = (int) child.getY();
    mStartWidth = child.getWidth();
    mStartHeight = child.getHeight();
    mStartAlpha = child.getAlpha();
    mStartRotateX = child.getRotationX();
    mStartRotateY = child.getRotationY();

    //特殊处理y方向变化
    if (mDependTargetY == UNSPECIFIED_INT && dependency instanceof AppBarLayout) {
        mDependTargetY = ((AppBarLayout) dependency).getTotalScrollRange();
    }
    // 背景颜色渐变
    if (child.getBackground() instanceof ColorDrawable) mStartBackgroundColor = ((ColorDrawable) child.getBackground()).getColor();
    // 自定义动画
    if (mAnimationId != 0) {
        mAnimation = AnimationUtils.loadAnimation(child.getContext(), mAnimationId);
        mAnimation.initialize(child.getWidth(), child.getHeight(), parent.getWidth(), parent.getHeight());
    }
    // 兼容5.0以上的沉浸模式
    if (Build.VERSION.SDK_INT > 16 && parent.getFitsSystemWindows() && targetY != UNSPECIFIED_INT) {
        targetY += getStatusBarHeight(parent.getContext());
    }
    isPrepared = true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:SimpleViewBehavior.java

示例3: updateVisibility

import android.view.View; //导入方法依赖的package包/类
public static void updateVisibility(View view, boolean accessibilityEnabled) {
    // We want to avoid the extra layout pass by setting the views to GONE unless
    // accessibility is on, in which case not setting them to GONE causes a glitch.
    int invisibleState = accessibilityEnabled ? View.GONE : View.INVISIBLE;
    if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != invisibleState) {
        view.setVisibility(invisibleState);
    } else if (view.getAlpha() > ALPHA_CUTOFF_THRESHOLD
            && view.getVisibility() != View.VISIBLE) {
        view.setVisibility(View.VISIBLE);
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:12,代码来源:WorkspaceStateTransitionAnimation.java

示例4: getAlpha

import android.view.View; //导入方法依赖的package包/类
public static float getAlpha(View view) {
    if (View10.NEED_PROXY) {
        return View10.wrap(view).getAlpha();
    } else {
        return view.getAlpha();
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:8,代码来源:ViewProxy.java

示例5: getViewBitmap

import android.view.View; //导入方法依赖的package包/类
public static Bitmap getViewBitmap(View comBitmap, int width, int height) {
    Bitmap bitmap = null;
    if (comBitmap != null) {
        comBitmap.clearFocus();
        comBitmap.setPressed(false);

        boolean willNotCache = comBitmap.willNotCacheDrawing();
        comBitmap.setWillNotCacheDrawing(false);

        // Reset the drawing cache background color to fully transparent
        // for the duration of this operation
        int color = comBitmap.getDrawingCacheBackgroundColor();
        comBitmap.setDrawingCacheBackgroundColor(0xffffff);
        float alpha = comBitmap.getAlpha();
        comBitmap.setAlpha(1.0f);

        if (color != 0) {
            comBitmap.destroyDrawingCache();
        }

        int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
        int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
        comBitmap.measure(widthSpec, heightSpec);
        comBitmap.layout(comBitmap.getLeft(), comBitmap.getTop(), comBitmap.getLeft()+width, comBitmap.getTop()+height);

        comBitmap.buildDrawingCache();
        Bitmap cacheBitmap = comBitmap.getDrawingCache();
        if (cacheBitmap == null) {
            Log.e("view.ProcessImageToBlur", "failed getViewBitmap(" + comBitmap);
            return null;
        }
        bitmap = Bitmap.createBitmap(cacheBitmap);
        // Restore the view
        comBitmap.setAlpha(alpha);
        comBitmap.destroyDrawingCache();
        comBitmap.setWillNotCacheDrawing(willNotCache);
        comBitmap.setDrawingCacheBackgroundColor(color);
    }
    return bitmap;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:41,代码来源:BitmapCommonUtils.java

示例6: updateScaleAndAlpha

import android.view.View; //导入方法依赖的package包/类
private void updateScaleAndAlpha(View view, float alpha, float scale) {
    if(null == view) {
        return;
    }
    if(alpha >= 0 && view.getAlpha() != alpha) {
        view.setAlpha(alpha);
    }
    if(scale >= 0 && view.getScaleX() != scale) {
        view.setScaleX(scale);
        view.setScaleY(scale);
    }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:13,代码来源:WXSliderNeighbor.java

示例7: animateFadeOut

import android.view.View; //导入方法依赖的package包/类
/**
 * Starts a fade out animation on the view.
 */
public static void animateFadeOut(View view) {

    view.animate().cancel();

    if (view.getAlpha() != 0f || view.getVisibility() == View.VISIBLE) {
        view.setVisibility(View.VISIBLE);
        view.setAlpha(1f);
        view.animate().alpha(0f).start();
    } else {
        view.setAlpha(0f);
        view.setVisibility(View.INVISIBLE);
    }
}
 
开发者ID:Frank1234,项目名称:FireBaseTest,代码行数:17,代码来源:ViewUtils.java

示例8: getValue

import android.view.View; //导入方法依赖的package包/类
private float getValue(int propertyConstant) {
    View v = (View) this.mView.get();
    if (v != null) {
        switch (propertyConstant) {
            case 1:
                return v.getTranslationX();
            case 2:
                return v.getTranslationY();
            case 4:
                return v.getScaleX();
            case 8:
                return v.getScaleY();
            case 16:
                return v.getRotation();
            case 32:
                return v.getRotationX();
            case 64:
                return v.getRotationY();
            case 128:
                return v.getX();
            case 256:
                return v.getY();
            case 512:
                return v.getAlpha();
        }
    }
    return 0.0f;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:ViewPropertyAnimatorHC.java

示例9: changeLocationBarIcon

import android.view.View; //导入方法依赖的package包/类
private void changeLocationBarIcon() {
    if (mLocationBarIconActiveAnimator != null && mLocationBarIconActiveAnimator.isRunning()) {
        mLocationBarIconActiveAnimator.cancel();
    }

    mLocationBarButtonType = getLocationBarButtonToShow();

    View viewToBeShown = null;
    switch (mLocationBarButtonType) {
        case BUTTON_TYPE_SECURITY_ICON:
            viewToBeShown = mSecurityButton;
            mLocationBarIconActiveAnimator = mSecurityButtonShowAnimator;
            break;
        case BUTTON_TYPE_NAVIGATION_ICON:
            viewToBeShown = mNavigationButton;
            mLocationBarIconActiveAnimator = mNavigationIconShowAnimator;
            break;
        case BUTTON_TYPE_NONE:
        default:
            mLocationBarIconActiveAnimator = null;
            return;
    }

    if (viewToBeShown.getVisibility() == VISIBLE && viewToBeShown.getAlpha() == 1) {
        return;
    }
    if (shouldAnimateIconChanges()) {
        mLocationBarIconActiveAnimator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    } else {
        mLocationBarIconActiveAnimator.setDuration(0);
    }
    mLocationBarIconActiveAnimator.start();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:34,代码来源:LocationBarLayout.java

示例10: Item

import android.view.View; //导入方法依赖的package包/类
public Item(View view, int width, int height) {
    this.view = view;
    this.width = width;
    this.height = height;
    alpha = view.getAlpha();
    x = 0;
    y = 0;
}
 
开发者ID:HitRoxxx,项目名称:FloatingNew,代码行数:9,代码来源:FloatingActionMenu.java

示例11: startAnimators

import android.view.View; //导入方法依赖的package包/类
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) {
    if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) {
        view.clearAnimation();
        view.animate().cancel();
        final Resources res = view.getResources();
        final float endAlpha = view.getAlpha();
        final float endTranslateX = view.getTranslationX();
        final float endTranslateY = view.getTranslationY();
        view.setAlpha(0);
        final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha);
        fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration));
        fade.setInterpolator(new AccelerateInterpolator());
        fade.setStartDelay(delay);
        fade.start();
        ViewPropertyAnimator slide = view.animate();
        if (startOffsetY != 0) {
            view.setTranslationY(startOffsetY);
            slide.translationY(endTranslateY);
        } else {
            view.setTranslationX(startOffsetX);
            slide.translationX(endTranslateX);
        }
        slide.setInterpolator(new DecelerateInterpolator(2));
        slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration));
        slide.setStartDelay(delay);
        slide.setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                if (fade.isStarted()) {
                    fade.cancel();
                }
                view.setAlpha(endAlpha);
                view.setTranslationX(endTranslateX);
                view.setTranslationY(endTranslateY);
            }
        });
        slide.start();
    }
}
 
开发者ID:rumaan,项目名称:AcademApp,代码行数:40,代码来源:MaterialIn.java

示例12: updateView

import android.view.View; //导入方法依赖的package包/类
public void updateView(View v) {
    if (v != null) {
        this.alpha = v.getAlpha();
        this.x = v.getX();
        this.y = v.getY();
        this.z = atLeastLollipop ? v.getZ() : 0;
        this.width = v.getWidth();
        this.height = v.getHeight();
        this.expansionScaleX = v.getScaleX();
        this.expansionScaleY = v.getScaleY();
        this.dispositionAngle = v.getRotation();
        this.dispositionAngleX = v.getRotationX();
        this.dispositionAngleY = v.getRotationY();
    }
}
 
开发者ID:rjsvieira,项目名称:morphos,代码行数:16,代码来源:ViewDefault.java

示例13: getAnimator

import android.view.View; //导入方法依赖的package包/类
@Override @NonNull
protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush) {
  AnimatorSet animator = new AnimatorSet();
  if (to != null) {
    float start = isPush ? 0 : to.getAlpha();
    animator.play(ObjectAnimator.ofFloat(to, View.ALPHA, start, 1));
  }

  if (from != null && !isPush) {
    animator.play(ObjectAnimator.ofFloat(from, View.ALPHA, 0));
  }

  return animator;
}
 
开发者ID:seven332,项目名称:conductor-attacher,代码行数:15,代码来源:FadeChangeHandler2.java

示例14: getAlpha

import android.view.View; //导入方法依赖的package包/类
static float getAlpha(View view) {
    return view.getAlpha();
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:4,代码来源:ViewHelper.java

示例15: getProperty

import android.view.View; //导入方法依赖的package包/类
@Override
protected float getProperty(View view) {
  return view.getAlpha();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:5,代码来源:OpacityAnimationPropertyUpdater.java


注:本文中的android.view.View.getAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。