Java tutorial
//package com.java2s; import android.os.Build; import android.widget.ImageView; public class Main { @SuppressWarnings("deprecation") public static void setAlpha(ImageView iv, int alpha) { if (iv.getBackground() != null) { iv.getBackground().setAlpha(alpha); return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { iv.setImageAlpha(alpha); } else { iv.setAlpha(alpha); } } }