兼容低版本的setAlpha()

/**
* 兼容低版本
*
* @param view
* @param alpha
*/
@SuppressLint("NewApi")
public static void setAlpha(View view, float alpha) { 
    if (Build.VERSION.SDK_INT < 11) { 
        final AlphaAnimation animation = new AlphaAnimation(alpha, alpha); 
        animation.setDuration(0); 
        animation.setFillAfter(true); 
        view.startAnimation(animation); 
    } else { 
        view.setAlpha(alpha); 
    }
}

你可能感兴趣的:(兼容低版本的setAlpha())