Example usage for android.view View getZ

List of usage examples for android.view View getZ

Introduction

In this page you can find the example usage for android.view View getZ.

Prototype

@ViewDebug.ExportedProperty(category = "drawing")
public float getZ() 

Source Link

Document

The visual z position of this view, in pixels.

Usage

From source file:com.augustosalazar.dragdroptest.DragFrameLayout.java

public DragFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mDragViews = new ArrayList<View>();

    /**//  w  w  w  .j  a va  2s.  co  m
     * Create the {@link ViewDragHelper} and set its callback.
     */
    mDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() {
        @Override
        public boolean tryCaptureView(View child, int pointerId) {
            return mDragViews.contains(child);
        }

        @Override
        public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
            super.onViewPositionChanged(changedView, left, top, dx, dy);
        }

        @Override
        public int clampViewPositionHorizontal(View child, int left, int dx) {
            return left;
        }

        @Override
        public int clampViewPositionVertical(View child, int top, int dy) {
            return top;
        }

        @Override
        public void onViewCaptured(View capturedChild, int activePointerId) {
            super.onViewCaptured(capturedChild, activePointerId);
            if (mDragFrameLayoutController != null) {
                mDragFrameLayoutController.onDragDrop(capturedChild, true);
            }
        }

        @Override
        public void onViewReleased(View releasedChild, float xvel, float yvel) {
            super.onViewReleased(releasedChild, xvel, yvel);
            if (mDragFrameLayoutController != null) {
                mDragFrameLayoutController.onDragDrop(releasedChild, false);
                releasedChild.setZ(releasedChild.getZ() + 0.54f);
            }
        }
    });
}