View 渐变显示与隐藏

/**
 * View 渐变显示与隐藏
 */
private void alphaAnim(final View view, boolean show){
    if(show) {
        view.setAlpha(0);
        view.setVisibility(View.VISIBLE);
        view.animate()
                .alpha(0.8f)
                .setDuration(500)
                .setListener(null);
    }else {
        view.animate()
                .alpha(0f)
                .setDuration(500)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        view.setVisibility(View.GONE);
                    }
                });
    }
}

你可能感兴趣的:(View 渐变显示与隐藏)