Android Bitmap to Drawable Convert bgColorDrawableSelector(Bitmap nomal, Bitmap focus)

Here you can find the source of bgColorDrawableSelector(Bitmap nomal, Bitmap focus)

Description

bg Color Drawable Selector

License

LGPL

Declaration

public static StateListDrawable bgColorDrawableSelector(Bitmap nomal,
            Bitmap focus) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.StateListDrawable;

public class Main {
    public static StateListDrawable bgColorDrawableSelector(Bitmap nomal,
            Bitmap focus) {/*from www.  j  a  v  a  2s . c o  m*/

        BitmapDrawable nomalBitmap = new BitmapDrawable(nomal);
        BitmapDrawable focusBitmap = new BitmapDrawable(focus);
        StateListDrawable selector = new StateListDrawable();
        selector.addState(new int[] { android.R.attr.state_pressed },
                focusBitmap);
        selector.addState(new int[] { android.R.attr.state_selected },
                focusBitmap);
        selector.addState(new int[] { android.R.attr.state_focused },
                focusBitmap);
        selector.addState(new int[] {}, nomalBitmap);
        return selector;
    }
}

Related

  1. from(Bitmap bitmap)
  2. BitmapToDrawable(final Bitmap bitmap)
  3. bitmapToDrawable(Bitmap bitmap)
  4. bitmapToTransitionDrawable( Bitmap bitmap)
  5. geRoundDrawableFromUrl(String url, int pixels)
  6. bitmapToDrawable(Bitmap bitmap)
  7. bitmapToTransitionDrawable( Bitmap bitmap)