Android examples for Graphics:Drawable
Create Transition Drawable
//package com.java2s; import android.content.Context; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; public class Main { public static TransitionDrawable CreateTransitionDrawable( int imgResource1, int imgResource2, Context mContext) { Drawable d[] = new Drawable[2]; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { d[0] = mContext.getDrawable(imgResource1); d[1] = mContext.getDrawable(imgResource2); } else {// ww w . j ava 2 s. c o m d[0] = mContext.getResources().getDrawable(imgResource1); d[1] = mContext.getResources().getDrawable(imgResource2); } return new TransitionDrawable(d); } }