Java Code Examples for android.view.View#setZ()

The following examples show how to use android.view.View#setZ() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MVHelper.java    From Tangram-Android with MIT License 4 votes vote down vote up
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);
            }
            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);
    }
}
 
Example 2
Source File: MVHelper.java    From Tangram-Android with MIT License 4 votes vote down vote up
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);
            }
            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);
    }
}
 
Example 3
Source File: ShadowHelperApi21.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static void setZ(View view, float z) {
    view.setZ(z);
}
 
Example 4
Source File: DynamicAnimation.java    From CircularReveal with MIT License 4 votes vote down vote up
@Override
public void setValue(View view, float value) {
  if (isZSupported()) {
    view.setZ(value);
  }
}