當前位置: 首頁>>代碼示例>>Java>>正文


Java View.setTranslationY方法代碼示例

本文整理匯總了Java中android.view.View.setTranslationY方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setTranslationY方法的具體用法?Java View.setTranslationY怎麽用?Java View.setTranslationY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.setTranslationY方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createShowItemAnimator

import android.view.View; //導入方法依賴的package包/類
private Animator createShowItemAnimator(View item) {

        float dx = fab.getX() - item.getX();
        float dy = fab.getY() - item.getY();

        item.setRotation(0f);
        item.setTranslationX(dx);
        item.setTranslationY(dy);

        Animator anim = ObjectAnimator.ofPropertyValuesHolder(
                item,
//                AnimatorUtils.rotation(0f, 720f),
                AnimatorUtils.translationX(dx, 0f),
                AnimatorUtils.translationY(dy, 0f)
        );

        return anim;
    }
 
開發者ID:xzg8023,項目名稱:ArcLayout-master,代碼行數:19,代碼來源:MainActivity.java

示例2: transformPage

import android.view.View; //導入方法依賴的package包/類
@Override
public void transformPage(View view, float position) {

    if (position < -1) {
        view.setAlpha(0);

    } else if (position <= 1) {
        view.setAlpha(1);

        view.setTranslationX(view.getWidth() * -position);

        float yPosition = position * view.getHeight();
        view.setTranslationY(yPosition);

    } else {
        view.setAlpha(0);
    }
}
 
開發者ID:willowtreeapps,項目名稱:spruce-android,代碼行數:19,代碼來源:VerticalViewPager.java

示例3: transformUnderlyingPage

import android.view.View; //導入方法依賴的package包/類
protected void transformUnderlyingPage(View page, float position, boolean enter) {
    page.setAlpha(1);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setTranslationX(0);
    page.setTranslationY(0);
    // Avoid overdraw
    page.setVisibility(View.INVISIBLE);
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:10,代碼來源:PageAnimator.java

示例4: runEnterAnimation

import android.view.View; //導入方法依賴的package包/類
private void runEnterAnimation(View view, int position) {
    if (position >= ANIMATED_ITEMS_COUNT - 1) {
        return;
    }


    if (scrollDirection == Constants.SCROLL_UP) {
        Log.d(LOG_TAG, "runEnterAnimation_up");
        if (position > lastAnimatedPosition) {
            lastAnimatedPosition = position;
            Log.d(LOG_TAG, "lasAnimated,position" + lastAnimatedPosition + "," + position);
            view.setTranslationY(Utils.getScreenHeight(mContext));
            ObjectAnimator objectAnimator= ObjectAnimator.ofFloat(view,"translationY",0);
            objectAnimator.setDuration(700)
                    .setInterpolator(new DecelerateInterpolator(3.f));
            objectAnimator.start();
        }
    } else {
        Log.d(LOG_TAG, "runEnterAnimation_down");
        if (position < lastAnimatedPosition) {
            Log.d(LOG_TAG, "lasAnimated,position" + lastAnimatedPosition + "," + position);
            lastAnimatedPosition = position;

        }
    }
}
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:27,代碼來源:FindRecyclerViewAdapter.java

示例5: transformPage

import android.view.View; //導入方法依賴的package包/類
public void transformPage(View view, float position, boolean horizontal) {
    int pageSize = horizontal ? view.getWidth() : view.getHeight();
    if (position < -1) { // [-Infinity,-1)way off-screen to the left
        view.setAlpha(MIN_ALPHA);
        view.setScaleX(MIN_SCALE);
        view.setScaleY(MIN_SCALE);
    } else if (position <= 1) { // [-1,1]
        float percent = 1 - Math.abs(position);
        float scale = MIN_SCALE + (1 - MIN_SCALE) * percent;
        if (mAdjustTranslate) {
            float horizontalMargin = pageSize * (1 - scale) / 2;
            if (position > 0) {
                if (horizontal) {
                    view.setTranslationX(horizontalMargin);
                } else {
                    view.setTranslationY(horizontalMargin);
                }
            } else {
                if (horizontal) {
                    view.setTranslationX(-horizontalMargin);
                } else {
                    view.setTranslationY(-horizontalMargin);
                }
            }
        }
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setAlpha(MIN_ALPHA + (1 - MIN_ALPHA) * percent);
    } else { // (1,+Infinity]page is way off-screen to the right.
        view.setAlpha(MIN_ALPHA);
        view.setScaleX(MIN_SCALE);
        view.setScaleY(MIN_SCALE);
    }
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:35,代碼來源:TestPageTransformer.java

示例6: transformPage

import android.view.View; //導入方法依賴的package包/類
@Override
public void transformPage(View view, float position) {
    float alpha = 0;
    if (0 <= position && position <= 1) {
        alpha = 1 - position;
    } else if (-1 < position && position < 0) {
        alpha = position + 1;
    }
    view.setAlpha(alpha);
    view.setTranslationX(view.getWidth() * -position);
    float yPosition = position * view.getHeight();
    view.setTranslationY(yPosition);
}
 
開發者ID:chadguo,項目名稱:VerticalViewPager,代碼行數:14,代碼來源:DefaultTransformer.java

示例7: offsetChildAsNeeded

import android.view.View; //導入方法依賴的package包/類
private void offsetChildAsNeeded(CoordinatorLayout parent, View child, View dependency) {
    float offsetRange = dependency.getTop() + getFinalHeight() - child.getTop();
    int headerOffsetRange = getHeaderOffsetRange();
    if (dependency.getTranslationY() == headerOffsetRange) {
        child.setTranslationY(offsetRange);
    } else if (dependency.getTranslationY() == 0) {
        child.setTranslationY(0);
    } else {
        child.setTranslationY((int) (dependency.getTranslationY() / (getHeaderOffsetRange() * 1.0f) * offsetRange));
    }
}
 
開發者ID:Learzhu,項目名稱:UcMainPagerDemo-master,代碼行數:12,代碼來源:UcNewsTabBehavior.java

示例8: runEnterAnimation

import android.view.View; //導入方法依賴的package包/類
private void runEnterAnimation(View view, int position) {
    if(position >= ANIMATED_ITEMS_COUNT - 1){//加載的item數大於等於屏幕所能裝下的item數則動畫加載完成(第一次加載前兩個item采用動畫效果)
        return;
    }
    if(position > lastAnimatedPosition){//lastAnimatedPosition初始值為-1,隨position增加不斷更新最後一個position的值
        lastAnimatedPosition = position;
        view.setTranslationY(Utils.getScreenHeight(mContext));//起始的Y點坐標為屏幕最下方
        view.animate()
                .translationY(0)
                .setInterpolator(new DecelerateInterpolator(3.f))
                .setDuration(700)
                .start();
    }
}
 
開發者ID:lianghao208,項目名稱:InstaFlickr,代碼行數:15,代碼來源:FeedAdapter.java

示例9: slidingByDelta

import android.view.View; //導入方法依賴的package包/類
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
       // ViewHelper.setTranslationY(view, delta);
    }
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:12,代碼來源:Instrument.java

示例10: resetViewProperty

import android.view.View; //導入方法依賴的package包/類
public static void resetViewProperty(View view) {
    view.setScaleX(1.0f);
    view.setScaleY(1.0f);
    view.setAlpha(1.0f);
    view.setTranslationX(0);
    view.setTranslationY(0);
    view.setRotation(0);
    view.setRotationX(0);
    view.setRotationY(0);
    view.animate().setStartDelay(0).setListener(null);
}
 
開發者ID:myl2ning,項目名稱:fragmentnav,代碼行數:12,代碼來源:Androids.java

示例11: onNestedPreScroll

import android.view.View; //導入方法依賴的package包/類
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dx, int dy, int[] consumed) {
    super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
    //dy>0 scroll up;dy<0,scroll down
    float halfOfDis = dy / 4.0f;
    if (!canScroll(child, halfOfDis)) {
        child.setTranslationY(halfOfDis > 0 ? getHeaderOffsetRange() : 0);
    } else {
        child.setTranslationY(child.getTranslationY() - halfOfDis);
    }
    //consumed all scroll behavior after we started Nested Scrolling
    consumed[1] = dy;
}
 
開發者ID:Learzhu,項目名稱:UcMainPagerDemo-master,代碼行數:14,代碼來源:UcNewsHeaderPagerBehavior.java

示例12: applyTranslationToTopChildViews

import android.view.View; //導入方法依賴的package包/類
private void applyTranslationToTopChildViews(ViewGroup contentView, float translation) {
    for (int i = 0; i < contentView.getChildCount(); i++) {
        View child = contentView.getChildAt(i);
        if (!(child.getLayoutParams() instanceof FrameLayout.LayoutParams)) continue;

        FrameLayout.LayoutParams layoutParams =
                (FrameLayout.LayoutParams) child.getLayoutParams();
        if (Gravity.TOP == (layoutParams.gravity & Gravity.FILL_VERTICAL)) {
            child.setTranslationY(translation);
            TraceEvent.instant("FullscreenManager:child.setTranslationY()");
        }
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:ChromeFullscreenManager.java

示例13: setValue

import android.view.View; //導入方法依賴的package包/類
/**
 * This method handles setting the property values directly in the View object's fields.
 * propertyConstant tells it which property should be set, value is the value to set
 * the property to.
 *
 * @param propertyConstant The property to be set
 * @param value The value to set the property to
 */
private void setValue(int propertyConstant, float value) {
    //final View.TransformationInfo info = mView.mTransformationInfo;
    View v = mView.get();
    if (v != null) {
        switch (propertyConstant) {
            case TRANSLATION_X:
                //info.mTranslationX = value;
                v.setTranslationX(value);
                break;
            case TRANSLATION_Y:
                //info.mTranslationY = value;
                v.setTranslationY(value);
                break;
            case ROTATION:
                //info.mRotation = value;
                v.setRotation(value);
                break;
            case ROTATION_X:
                //info.mRotationX = value;
                v.setRotationX(value);
                break;
            case ROTATION_Y:
                //info.mRotationY = value;
                v.setRotationY(value);
                break;
            case SCALE_X:
                //info.mScaleX = value;
                v.setScaleX(value);
                break;
            case SCALE_Y:
                //info.mScaleY = value;
                v.setScaleY(value);
                break;
            case X:
                //info.mTranslationX = value - v.mLeft;
                v.setX(value);
                break;
            case Y:
                //info.mTranslationY = value - v.mTop;
                v.setY(value);
                break;
            case ALPHA:
                //info.mAlpha = value;
                v.setAlpha(value);
                break;
        }
    }
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:57,代碼來源:ViewPropertyAnimatorHC.java

示例14: setTranslationY

import android.view.View; //導入方法依賴的package包/類
public static void setTranslationY(View view, float value) {
    view.setTranslationY(value);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:ViewCompatHC.java

示例15: transformPage

import android.view.View; //導入方法依賴的package包/類
@Override
public void transformPage(View page, float position) {
    page.setTranslationX(page.getWidth() * -position);
    page.setTranslationY(position < 0 ? position * page.getHeight() : 0f);
}
 
開發者ID:chadguo,項目名稱:VerticalViewPager,代碼行數:6,代碼來源:StackTransformer.java


注:本文中的android.view.View.setTranslationY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。