bitmap to Transition Drawable - Android Graphics

Android examples for Graphics:Drawable

Description

bitmap to Transition Drawable

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;

public class Main {

    @SuppressWarnings("ResourceType")
    public static TransitionDrawable bitmap2TransitionDrawable(Bitmap bitmap) {
        TransitionDrawable mBitmapDrawable = null;
        try {/*from w  w w . ja  v  a  2s  .c o m*/
            if (bitmap == null) {
                return null;
            }
            mBitmapDrawable = new TransitionDrawable(new Drawable[] {
                    new ColorDrawable(android.R.color.transparent),
                    new BitmapDrawable(null, bitmap) });
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mBitmapDrawable;
    }
}

Related Tutorials