Java Code Examples for android.support.v4.view.ViewCompat#setTranslationZ()

The following examples show how to use android.support.v4.view.ViewCompat#setTranslationZ() . 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: MinimalKSnack.java    From KSnack with Apache License 2.0 6 votes vote down vote up
private void initializeMinimalBar(View parentView){
    linf = (LayoutInflater) parentView.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    insertPoint = (ViewGroup) parentView;

    // Create view.
    snackView = linf.inflate(R.layout.layout_snack_small, null);
    snackView.setVisibility(View.GONE);
    ViewCompat.setTranslationZ(snackView, 999);
    insertPoint.addView(snackView, -1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    // Initialize component view.
    lnrSnack = snackView.findViewById(R.id.minimal_snack_bar_lnr);

    // Set default in anim.
    inAnim = Fade.In.getAnimation();

    // Set default out anim.
    outAnim = Fade.Out.getAnimation();
}
 
Example 2
Source File: FloatingToolbar.java    From FloatingToolbar with Apache License 2.0 6 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (!(state instanceof SavedState)) {
        super.onRestoreInstanceState(state);
        return;
    }

    SavedState savedState = (SavedState) state;

    super.onRestoreInstanceState(savedState.getSuperState());

    if (savedState.morphed) {
        mShowing = true;
        ViewCompat.setTranslationZ(this,
                getResources().getDimension(R.dimen.floatingtoolbar_translationz));
        setVisibility(View.VISIBLE);
        mFab.setVisibility(View.INVISIBLE);
    }
}
 
Example 3
Source File: ScannerActivity.java    From attendee-checkin with Apache License 2.0 6 votes vote down vote up
@Override
public void onGlobalLayout() {
    SlidingUpPanelLayout.PanelState state = mPanelLayout.getPanelState();
    if (state == SlidingUpPanelLayout.PanelState.COLLAPSED) {
        for (int i = 1; i < mTabs.length; i++) {
            mTabs[i].setAlpha(0.f);
        }
        mTabs[0].setTextColor(mColorTabSelected);
        mTabs[0].setTranslationX(TIMELINE_TRANSLATION_X);
        ViewCompat.setTranslationZ(mTabLayout, 0);
        mTabLayout.setEnabled(false);
        mTabLayout.setTabIndicatorColor(Color.TRANSPARENT);
    } else if (state == SlidingUpPanelLayout.PanelState.EXPANDED) {
        for (int i = 1; i < mTabs.length; i++) {
            mTabs[i].setAlpha(1.f);
        }
        mTabs[0].setTranslationX(0.f);
        ViewCompat.setTranslationZ(mTabLayout, mToolbarElevation);
        mTabLayout.setEnabled(true);
        mTabLayout.setTabIndicatorColor(mColorTabIndicator);
    }
    mTabLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
 
Example 4
Source File: ScannerActivity.java    From attendee-checkin with Apache License 2.0 6 votes vote down vote up
@Override
public void onPanelSlide(View view, float v) {
    // v: 0 (collapsed), 1 (expanded)
    for (int i = 1; i < mTabs.length; i++) {
        mTabs[i].setAlpha(v);
    }
    mTabs[0].setTranslationX(TIMELINE_TRANSLATION_X * (1 - v));
    ViewCompat.setTranslationZ(mTabLayout, mToolbarElevation * v);
    mTabLayout.setTabIndicatorColor(Color.argb((int) (0xff * v),
            Color.red(mColorTabIndicator),
            Color.green(mColorTabIndicator),
            Color.blue(mColorTabIndicator)));
    if (mLastAnimator != null) {
        mLastAnimator.cancel();
        mLastAnimator = null;
    }
}
 
Example 5
Source File: BaseItemAnimator.java    From MultiView with Apache License 2.0 6 votes vote down vote up
protected void resetView(View view) {
    Log.v("resetView: " + view);
    ViewCompat.setAlpha(view, 1);
    ViewCompat.setTranslationX(view, 0);
    ViewCompat.setTranslationY(view, 0);
    ViewCompat.setTranslationZ(view, 0);
    ViewCompat.setRotation(view, 0);
    ViewCompat.setRotationX(view, 0);
    ViewCompat.setRotationY(view, 0);
    ViewCompat.setScaleX(view, 1);
    ViewCompat.setScaleY(view, 1);
    ViewCompat.setPivotY(view, view.getMeasuredHeight() / 2);
    ViewCompat.setPivotX(view, view.getMeasuredWidth() / 2);
    ViewCompat.animate(view).setInterpolator(null);

    //do we need it at all ?
    // view.invalidate();
}
 
Example 6
Source File: ChangeTransform.java    From scene with Apache License 2.0 5 votes vote down vote up
private static void setTransforms(View view, float translationX, float translationY,
                                  float translationZ, float scaleX, float scaleY, float rotationX,
                                  float rotationY, float rotationZ) {
    view.setTranslationX(translationX);
    view.setTranslationY(translationY);
    ViewCompat.setTranslationZ(view, translationZ);
    view.setScaleX(scaleX);
    view.setScaleY(scaleY);
    view.setRotationX(rotationX);
    view.setRotationY(rotationY);
    view.setRotation(rotationZ);
}
 
Example 7
Source File: KSnack.java    From KSnack with Apache License 2.0 5 votes vote down vote up
private void initializeKSnackBar(View parentView) {
    linf = (LayoutInflater) parentView.getContext().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    insertPoint = (ViewGroup) parentView;

    // Create view.
    snackView = linf.inflate(R.layout.layout_snack_normal, null);

    snackView.setVisibility(View.GONE);

    ViewCompat.setTranslationZ(snackView, 999);
    insertPoint.addView(snackView, 1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    // Initialize component view.
    rlvHost = snackView.findViewById(R.id.normal_snack_bar_rlv);

    // Initialize textview.
    txtMessage = snackView.findViewById(R.id.snack_bar_txt_message);

    // Action button.
    btnAction = snackView.findViewById(R.id.snack_bar_btn_action);

    // Set default in anim.
    inAnim = Fade.In.getAnimation();

    // Set default out anim.
    outAnim = Fade.Out.getAnimation();
}
 
Example 8
Source File: MainActivity.java    From star-dns-changer with MIT License 5 votes vote down vote up
private void initViews() {
    toolbar.setTitle("");
    setSupportActionBar(toolbar);
    logo.bringToFront();
    logo.requestLayout();
    logo.invalidate();

    InputFilter[] filters = new InputFilter[1];
    filters[0] = new InputFilter() {
        @Override
        public CharSequence filter(CharSequence source, int start,
                                   int end, Spanned dest, int dstart, int dend) {
            if (end > start) {
                String destTxt = dest.toString();
                String resultingTxt = destTxt.substring(0, dstart) +
                        source.subSequence(start, end) +
                        destTxt.substring(dend);
                if (!resultingTxt.matches("^\\d{1,3}(\\." +
                        "(\\d{1,3}(\\.(\\d{1,3}(\\.(\\d{1,3})?)?)?)?)?)?")) {
                    return "";
                } else {
                    String[] splits = resultingTxt.split("\\.");
                    for (int i = 0; i < splits.length; i++) {
                        if (Integer.valueOf(splits[i]) > 255) {
                            return "";
                        }
                    }
                }
            }
            return null;
        }
    };
    firstDnsEdit.setFilters(filters);
    secondDnsEdit.setFilters(filters);
    ViewCompat.setTranslationZ(logo, 8);
}
 
Example 9
Source File: PropertySetter.java    From StickyScrollView with MIT License 5 votes vote down vote up
public static void setTranslationZ(View view, float translationZ) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ViewCompat.setTranslationZ(view, translationZ);
    } else if (translationZ != 0) {
        view.bringToFront();
        if (view.getParent() != null) {
            ((View) view.getParent()).invalidate();
        }
    }
}
 
Example 10
Source File: TurnCardListView.java    From turncardlistview with Apache License 2.0 5 votes vote down vote up
void resetChild(View child, int n, float width) {
    float scale = (width + offsetsX[n]) / width;
    child.setPivotY(0);
    child.setPivotX(width / 2);
    child.setScaleY(scale);
    child.setScaleX(scale);
    child.setTranslationY(offsetsY[n]);
    child.setAlpha(n == 0 ? 0 : 1);
    ViewCompat.setTranslationZ(child, n - MAX_CHILD_COUNT);
}
 
Example 11
Source File: SwipeDeck.java    From Swipe-Deck with MIT License 5 votes vote down vote up
public SwipeDeck(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.SwipeDeck,
            0, 0);
    try {
        NUMBER_OF_CARDS = a.getInt(R.styleable.SwipeDeck_max_visible, 3);
        ROTATION_DEGREES = a.getFloat(R.styleable.SwipeDeck_rotation_degrees, 15f);
        CARD_SPACING = a.getDimension(R.styleable.SwipeDeck_card_spacing, 15f);
        RENDER_ABOVE = a.getBoolean(R.styleable.SwipeDeck_render_above, true);
        RENDER_BELOW = a.getBoolean(R.styleable.SwipeDeck_render_below, false);
        CARD_GRAVITY = a.getInt(R.styleable.SwipeDeck_card_gravity, 0);
        OPACITY_END = a.getFloat(R.styleable.SwipeDeck_opacity_end, 0.33f);
    } finally {
        a.recycle();
    }

    paddingBottom = getPaddingBottom();
    paddingLeft = getPaddingLeft();
    paddingRight = getPaddingRight();
    paddingTop = getPaddingTop();

    //set clipping of view parent to false so cards render outside their view boundary
    //make sure not to clip to padding
    setClipToPadding(false);
    setClipChildren(false);

    this.setWillNotDraw(false);

    //render the cards and card deck above or below everything
    if (RENDER_ABOVE) {
        ViewCompat.setTranslationZ(this, Float.MAX_VALUE);
    }
    if (RENDER_BELOW) {
        ViewCompat.setTranslationZ(this, Float.MIN_VALUE);
    }
}
 
Example 12
Source File: StackZFragment.java    From support with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    int count = ((ViewGroup) view).getChildCount();
    for (int i = 0; i < count; i++) {
        View card = ((ViewGroup) view).getChildAt(i);
        ViewCompat.setTranslationZ(card, (i + 1) * 8 * getResources().getDisplayMetrics().density);
    }
}
 
Example 13
Source File: AttendeeListFragment.java    From attendee-checkin with Apache License 2.0 5 votes vote down vote up
public void bind(Cursor cursor, ImageLoader imageLoader) {
    itemView.setBackgroundDrawable(null);
    ViewCompat.setTranslationZ(itemView, 0.f);
    mName.setText(cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.NAME)));
    mEmail.setText(cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.EMAIL)));
    String note = cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.NOTE));
    mNote.setVisibility(TextUtils.isEmpty(note) ? View.GONE : View.VISIBLE);
    mNote.setText(note);
    mEventId = cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.EVENT_ID));
    mAttendeeId = cursor.getString(cursor.getColumnIndexOrThrow(Table.Attendee.ID));
    mAttendeeCheckedIn = !cursor.isNull(cursor.getColumnIndexOrThrow(Table.Attendee.CHECKIN));
    mCheckin.setVisibility(mAttendeeCheckedIn ? View.VISIBLE : View.INVISIBLE);
    mActionCheck.setImageResource(mAttendeeCheckedIn ?
            R.drawable.ic_check_green : R.drawable.ic_check_gray);
    boolean modified = 0 != cursor.getInt(cursor.getColumnIndexOrThrow(Table.Attendee.CHECKIN_MODIFIED));
    mSyncInProcess.setVisibility(modified && BuildConfig.DEBUG ?
            View.VISIBLE : View.INVISIBLE);
    mActions.setVisibility(View.GONE);
    itemView.setOnClickListener(this);
    mActionCheck.setOnClickListener(this);
    mActionEdit.setOnClickListener(this);
    // Icon
    ImageLoader.ImageContainer container = (ImageLoader.ImageContainer)
            mIcon.getTag();
    if (container != null) {
        container.cancelRequest();
    }
    int columnIndexImageUrl = cursor.getColumnIndexOrThrow(Table.Attendee.IMAGE_URL);
    if (!cursor.isNull(columnIndexImageUrl)) {
        mIcon.setTag(imageLoader.get(cursor.getString(columnIndexImageUrl),
                new RoundedImageListener(mIcon,
                        R.drawable.ic_person, R.drawable.ic_person)));
    } else {
        mIcon.setImageResource(R.drawable.ic_person);
    }
}
 
Example 14
Source File: AttendeeListFragment.java    From attendee-checkin with Apache License 2.0 5 votes vote down vote up
private void expand() {
    ViewCompat.setScaleY(mActions, 0.f);
    mActions.setVisibility(View.VISIBLE);
    ViewCompat.animate(mActions)
            .setInterpolator(new FastOutSlowInInterpolator())
            .scaleY(1.f)
            .setListener(null)
            .start();
    itemView.setBackgroundColor(Color.rgb(0xf8, 0xf8, 0xf8));
    ViewCompat.setTranslationZ(itemView, 8.f);
}
 
Example 15
Source File: AttendeeListFragment.java    From attendee-checkin with Apache License 2.0 5 votes vote down vote up
private void shrink() {
    ViewCompat.animate(mActions)
            .setInterpolator(new FastOutSlowInInterpolator())
            .scaleY(0.f)
            .setListener(new EasyAnimatorListener() {
                @Override
                public void onAnimationEnd(View view) {
                    mActions.setVisibility(View.GONE);
                }
            }).start();
    itemView.setBackgroundDrawable(null);
    ViewCompat.setTranslationZ(itemView, 0.f);
}