Hello.
How to set DragShadowBuilder alpha value?
I tried this, but it doesn't work.

private class CustomShadow extends View.DragShadowBuilder {
    private View mView;

    private Drawable shadow;

    public CustomShadow(View view) {
        super();
        mView = view;
        shadow = new BitmapDrawable(context.getResources(), 
getBitmapFromView(mView));
        shadow.setBounds(0, 0, shadow.getMinimumWidth(), 
shadow.getMinimumHeight());
        shadow.setAlpha(255);
    }

    @Override
    public void onDrawShadow(Canvas canvas) {
        shadow.draw(canvas);
    }

    @Override
    public void onProvideShadowMetrics(Point shadowSize, Point 
shadowTouchPoint) {
        //super.onProvideShadowMetrics(shadowSize, shadowTouchPoint);

        shadowSize.x = shadow.getMinimumWidth();
        shadowSize.y = shadow.getMinimumHeight();

        shadowTouchPoint.x = shadowSize.x / 2;
        shadowTouchPoint.y = shadowSize.y / 2;
    }

    public Bitmap getBitmapFromView(View view) {
        //Define a bitmap with the same size as the view
        Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), 
view.getHeight(), Bitmap.Config.ARGB_8888);
        //Bind a canvas to it
        Canvas canvas = new Canvas(returnedBitmap);
        //Get the view's background
        Drawable bgDrawable = view.getBackground();
        if (bgDrawable != null)
            //has background drawable, then draw it on the canvas
            bgDrawable.draw(canvas);
        else
            //does not have background drawable, then draw white background on 
the canvas
            canvas.drawColor(Color.WHITE);
        // draw the view on the canvas
        view.draw(canvas);
        //return the bitmap
        return returnedBitmap;
    }
}


Please help me!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/882dd4da-6a83-469e-a343-16619155b505%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to