Example usage for android.view View setZ

List of usage examples for android.view View setZ

Introduction

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

Prototype

public void setZ(float z) 

Source Link

Document

Sets 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>();

    /**// www .  j  a va2  s. c om
     * 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);
            }
        }
    });
}

From source file:com.tmall.wireless.tangram3.MVHelper.java

protected void renderLayout(BaseCell cell, View view) {
    if (cell.style != null) {
        ViewGroup.LayoutParams lp = view.getLayoutParams();

        if (lp == null || !(lp instanceof VirtualLayoutManager.LayoutParams)) {
            if (lp == null) {
                lp = new VirtualLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
            } else {
                lp = new VirtualLayoutManager.LayoutParams(lp.width, lp.height);
            }/* www.j  a v a 2s. co  m*/
            view.setLayoutParams(lp);
        }
        if (lp instanceof VirtualLayoutManager.LayoutParams) {
            VirtualLayoutManager.LayoutParams params = (VirtualLayoutManager.LayoutParams) lp;

            if (cell.style.height >= 0) {
                params.storeOriginHeight();
                params.height = cell.style.height;
            } else {
                params.restoreOriginHeight();
            }

            if (cell.style.width >= 0) {
                params.storeOriginWidth();
                params.width = cell.style.width;
            } else {
                params.restoreOriginWidth();
            }

            params.mAspectRatio = cell.style.aspectRatio;

            params.zIndex = cell.style.zIndex;
            if (params.zIndex == 0) {
                if (cell.parent != null && cell.parent.style != null) {
                    params.zIndex = cell.parent.style.zIndex;
                }
            }
            if (VERSION.SDK_INT >= 21) {
                view.setZ(params.zIndex);
            }
        } else {
            if (cell.style.height >= 0) {
                lp.height = cell.style.height;
            }

            if (cell.style.width >= 0) {
                lp.width = cell.style.width;
            }
        }

        if (lp instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) lp;
            layoutParams.topMargin = cell.style.margin[MARGIN_TOP_INDEX];
            layoutParams.leftMargin = cell.style.margin[MARGIN_LEFT_INDEX];
            layoutParams.bottomMargin = cell.style.margin[MARGIN_BOTTOM_INDEX];
            layoutParams.rightMargin = cell.style.margin[MARGIN_RIGHT_INDEX];
        }

        // reset translation animation before reused
        view.setTranslationX(0);
        view.setTranslationY(0);
    }
}