使用TransitionDrawable实现渐变效果

    private void setImageBitmap(ImageView imageView, Bitmap bitmap) {  
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {  
                new ColorDrawable(android.R.color.transparent),  
                new BitmapDrawable(getResources(), bitmap) });  
        imageView.setBackgroundDrawable(imageView.getDrawable());  
        imageView.setImageDrawable(td);  
        td.startTransition(200);  
    }  

编程技巧