daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Oct 15th, 2018 65 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. public class ImageDragShadowBuilder extends View.DragShadowBuilder {
  2.  
  3. public ImageDragShadowBuilder(View v) {
  4.     super(v);
  5. }
  6.  
  7.  
  8. @Override
  9. public void onProvideShadowMetrics(Point shadowSize, Point touchPoint) {
  10.     shadowSize.set(getView().getWidth()*2, getView().getHeight()*2);
  11.     touchPoint.set(getView().getWidth() / 2, getView().getHeight() / 2);
  12.  
  13. }}
  14.    
  15. private static class MyDragShadowBuilder extends View.DragShadowBuilder {
  16.  
  17.     private Point mScaleFactor;
  18.         // Defines the constructor for myDragShadowBuilder
  19.         public MyDragShadowBuilder(View v) {
  20.  
  21.             // Stores the View parameter passed to myDragShadowBuilder.
  22.             super(v);
  23.  
  24.         }
  25.  
  26.         // Defines a callback that sends the drag shadow dimensions and touch point back to the
  27.         // system.
  28.         @Override
  29.         public void onProvideShadowMetrics (Point size, Point touch) {
  30.             // Defines local variables
  31.             int width;
  32.             int height;
  33.  
  34.             // Sets the width of the shadow to half the width of the original View
  35.             width = getView().getWidth() / 2;
  36.  
  37.             // Sets the height of the shadow to half the height of the original View
  38.             height = getView().getHeight() / 2;
  39.  
  40.             // Sets the size parameter's width and height values. These get back to the system
  41.             // through the size parameter.
  42.             size.set(width, height);
  43.             // Sets size parameter to member that will be used for scaling shadow image.
  44.             mScaleFactor = size;
  45.  
  46.             // Sets the touch point's position to be in the middle of the drag shadow
  47.             touch.set(width / 2, height / 2);
  48.         }
  49.  
  50.         @Override
  51.         public void onDrawShadow(Canvas canvas) {
  52.  
  53.             // Draws the ColorDrawable in the Canvas passed in from the system.
  54.             canvas.scale(mScaleFactor.x/(float)getView().getWidth(), mScaleFactor.y/(float)getView().getHeight());
  55.             getView().draw(canvas);
  56.         }
  57.  
  58.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top