Java Code Examples for android.view.View.setTranslationZ()

The following are Jave code examples for showing how to use setTranslationZ() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: backstack   File: Helper.java   Source Code and License Vote up 7 votes
/**
 * Helper function to disable a ViewGroup and all it's children. This draws a new view with z-ordering of integer max
 * that consumes all touch events.
 * @param viewGroup
 */
public static void disable(ViewGroup viewGroup){
    View view = new View(viewGroup.getContext());
    viewGroup.addView(view);
    view.setTag(DISABLE);

    ViewGroup.LayoutParams params = view.getLayoutParams();
    params.height = MATCH_PARENT;
    params.width = MATCH_PARENT;
    view.setLayoutParams(params);

    view.setClickable(true);
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(Color.TRANSPARENT);

    if (Build.VERSION.SDK_INT >= 21) {
        view.setTranslationZ(Integer.MAX_VALUE);
    }
    viewGroup.bringChildToFront(view);
}
 
Example 2
Project: MzViewPager   File: ScaleYTransformer.java   Source Code and License Vote up 6 votes
@Override
public void transformPage(View page, float position) {
    if (position > -1 && position < 1) {
        float scale = Math.max(MIN_SCALE, MAX_SCALE - Math.abs(position) * (MAX_SCALE - MIN_SCALE));
        page.setScaleY(scale);
        page.setScaleX(scale);
        float transZ = Math.max(MIN_TRANSLATION_Z, MAX_TRANSLATION_Z - Math.abs(position)
                * (MAX_TRANSLATION_Z - MIN_TRANSLATION_Z));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            page.setTranslationZ(transZ);
        }
        if (position == 0) {
            Log.e(TAG, "transformPage执行scale 被执行者:" + page.toString());
        }
    } else {
        page.setScaleY(MIN_SCALE);
        page.setScaleX(MIN_SCALE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            page.setTranslationZ(MIN_TRANSLATION_Z);
        }
    }
}
 
Example 3
Project: FlipLayout   File: FlipLayout.java   Source Code and License Vote up 6 votes
private void restoreView(View v) {
    v.setVisibility(endVisibility);
    v.setPivotY(v.getHeight() / 2);
    v.setPivotX(v.getWidth() / 2);
    v.setRotation(0);
    v.setRotationX(0);
    v.setRotationY(0);
    v.setTranslationX(0);
    v.setTranslationY(0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        v.setTranslationZ(0);
    }
}
 
Example 4
Project: GitHub   File: WoWoTranslation3DAnimation.java   Source Code and License Vote up 4 votes
@Override
protected void toStartState(View view) {
    view.setTranslationX(fromX);
    view.setTranslationY(fromY);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) view.setTranslationZ(fromZ);
}
 
Example 5
Project: GitHub   File: WoWoTranslation3DAnimation.java   Source Code and License Vote up 4 votes
@Override
protected void toMiddleState(View view, float offset) {
    view.setTranslationX(fromX + (toX - fromX) * offset);
    view.setTranslationY(fromY + (toY - fromY) * offset);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) view.setTranslationZ(fromZ + (toZ - fromZ) * offset);
}
 
Example 6
Project: GitHub   File: WoWoTranslation3DAnimation.java   Source Code and License Vote up 4 votes
@Override
protected void toEndState(View view) {
    view.setTranslationX(toX);
    view.setTranslationY(toY);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) view.setTranslationZ(toZ);
}
 
Example 7
Project: duo-navigation-drawer   File: DuoDrawerLayout.java   Source Code and License Vote up 4 votes
/**
 * Adds a touch interceptor to the layout when needed.
 * The interceptor wil take care of touch events occurring
 * on the content view when the drawer is open.
 */
private void addTouchInterceptor() {
    View touchInterceptor = mLayoutInflater.inflate(R.layout.duo_overlay, this, false);
    touchInterceptor.setTag(TAG_OVERLAY);
    touchInterceptor.setOnTouchListener(new OnTouchListener() {
        float startX;
        float startY;

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (mLockMode != LOCK_MODE_LOCKED_OPEN) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        startX = event.getX();
                        startY = event.getY();
                        break;
                    case MotionEvent.ACTION_UP:
                        float endX = event.getX();
                        float endY = event.getY();

                        if (touchIsClick(startX, endX, startY, endY)) {
                            closeDrawer();
                        }
                        break;
                    case MotionEvent.ACTION_MOVE:
                        mViewDragCallback.mIsEdgeDrag = true;
                        int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
                        mViewDragHelper.captureChildView(mContentView, pointerIndex);
                        break;
                }
                return true;
            } else return true;
        }
    });


    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        touchInterceptor.setTranslationZ(MAX_ATTRIBUTE_MULTIPLIER);
    }

    addView(touchInterceptor);
}
 
Example 8
Project: letv   File: ViewCompatLollipop.java   Source Code and License Vote up 4 votes
public static void setTranslationZ(View view, float translationZ) {
    view.setTranslationZ(translationZ);
}
 
Example 9
Project: boohee_v5.6   File: ViewCompatLollipop.java   Source Code and License Vote up 4 votes
public static void setTranslationZ(View view, float translationZ) {
    view.setTranslationZ(translationZ);
}