android.support.v4.view.ViewCompat#setTranslationZ ( )源码实例Demo

下面列出了android.support.v4.view.ViewCompat#setTranslationZ ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: KSnack   文件: MinimalKSnack.java
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();
}
 
源代码2 项目: FloatingToolbar   文件: FloatingToolbar.java
@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);
    }
}
 
源代码3 项目: attendee-checkin   文件: ScannerActivity.java
@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);
}
 
源代码4 项目: attendee-checkin   文件: ScannerActivity.java
@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;
    }
}
 
源代码5 项目: MultiView   文件: BaseItemAnimator.java
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();
}
 
源代码6 项目: scene   文件: ChangeTransform.java
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);
}
 
源代码7 项目: KSnack   文件: KSnack.java
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();
}
 
源代码8 项目: star-dns-changer   文件: MainActivity.java
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);
}
 
源代码9 项目: StickyScrollView   文件: PropertySetter.java
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();
        }
    }
}
 
源代码10 项目: turncardlistview   文件: TurnCardListView.java
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);
}
 
源代码11 项目: Swipe-Deck   文件: SwipeDeck.java
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);
    }
}
 
源代码12 项目: support   文件: StackZFragment.java
@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);
    }
}
 
源代码13 项目: attendee-checkin   文件: AttendeeListFragment.java
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);
    }
}
 
源代码14 项目: attendee-checkin   文件: AttendeeListFragment.java
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);
}
 
源代码15 项目: attendee-checkin   文件: AttendeeListFragment.java
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);
}
 
 同类方法