当前位置: 首页>>代码示例>>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;未经允许,请勿转载。