Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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 {
            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;
    }
}