当前位置: 首页>>代码示例>>Java>>正文


Java View.setX方法代码示例

本文整理汇总了Java中android.view.View.setX方法的典型用法代码示例。如果您正苦于以下问题:Java View.setX方法的具体用法?Java View.setX怎么用?Java View.setX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSwipeNeighborLayoutListener

import android.view.View; //导入方法依赖的package包/类
/**
 * Creates and returns a layout listener, which allows to position a tab, which is a neighbor of
 * the currently selected tab, when swiping horizontally.
 *
 * @param neighbor
 *         The tab item, which corresponds to the neighboring tab, as an instance of the class
 *         {@link TabItem}. The tab item may not be null
 * @param dragDistance
 *         The distance of the swipe gesture in pixels as a {@link Float} value
 * @return The layout listener, which has been created, as an instance of the type {@link
 * OnGlobalLayoutListener}. The layout listener may not be null
 */
@NonNull
private OnGlobalLayoutListener createSwipeNeighborLayoutListener(
        @NonNull final TabItem neighbor, final float dragDistance) {
    return new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            View view = contentViewRecycler.getView(neighbor.getTab());

            if (view != null) {
                float position;

                if (dragDistance > 0) {
                    position = -getTabSwitcher().getWidth() + dragDistance - swipedTabDistance;
                } else {
                    position = getTabSwitcher().getWidth() + dragDistance + swipedTabDistance;
                }

                view.setX(position);
            }
        }

    };
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:37,代码来源:TabletTabSwitcherLayout.java

示例2: createAddSelectedTabLayoutListener

import android.view.View; //导入方法依赖的package包/类
/**
 * Creates and returns a layout listener, which allows to show a tab as the currently selected
 * one, once it view has been inflated.
 *
 * @param item
 *         The item, which corresponds to the tab, which has been added, as an instance of the
 *         class {@link AbstractItem}. The item may not be null
 * @return The listener, which has been created, as an instance of the type {@link
 * OnGlobalLayoutListener}. The listener may not be null
 */
@NonNull
private OnGlobalLayoutListener createAddSelectedTabLayoutListener(
        @NonNull final AbstractItem item) {
    return new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            View view = item.getView();
            FrameLayout.LayoutParams layoutParams =
                    (FrameLayout.LayoutParams) view.getLayoutParams();
            view.setAlpha(1f);
            getArithmetics().setPivot(Axis.DRAGGING_AXIS, item,
                    getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE));
            getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
                    getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE));
            view.setX(layoutParams.leftMargin);
            view.setY(layoutParams.topMargin);
            getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1);
            getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1);
        }

    };
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:34,代码来源:PhoneTabSwitcherLayout.java

示例3: setPosition

import android.view.View; //导入方法依赖的package包/类
@Override
public final void setPosition(@NonNull final Axis axis, @NonNull final AbstractItem item,
                              final float position) {
    ensureNotNull(axis, "The axis may not be null");
    ensureNotNull(item, "The item may not be null");
    View view = item.getView();

    if (axis == Axis.DRAGGING_AXIS) {
        Toolbar[] toolbars = getTabSwitcher().getToolbars();
        view.setX((getTabSwitcher().areToolbarsShown() && toolbars != null ? Math.max(0,
                toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].getWidth() - tabOffset) : 0) +
                position);
    } else {
        view.setY((tabContainerHeight - tabHeight) + position);
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:17,代码来源:TabletArithmetics.java

示例4: initChild

import android.view.View; //导入方法依赖的package包/类
private void initChild(int l, int t, int r, int b) {
    int clientCount = getChildCount();
    mPagerView.bringToFront();
    mActiveView = getChildAt(mActiveChildIndex);
    for (int i = 0; i < clientCount; i++) {
        View child = getChildAt(i);
        if (child == mPagerView) {
            child.setX(0);
            continue;
        }
        if (mNew) {
            child.setX(child == mActiveView ? 0 : getWidth());
        }
    }
    mNew = false;

}
 
开发者ID:savmm,项目名称:AndroidSimpleViews,代码行数:18,代码来源:SimpleViewPager.java

示例5: onDependentViewChanged

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    maybeInitProperties((ImageView) child, dependency);

    final int maxScrollDistance = (int) (startToolbarPosition - getStatusBarHeight());
    float expandedPercentageFactor = dependency.getY() / maxScrollDistance;

    float distanceYToSubtract = ((startYPosition - finalYPosition)
            * (1f - expandedPercentageFactor)) + (child.getHeight() / 2);

    float distanceXToSubtract = ((startXPosition - finalXPosition)
            * (1f - expandedPercentageFactor)) + (child.getWidth() / 2);

    float heightToSubtract = ((startHeight - finalHeight) * (1f - expandedPercentageFactor));

    child.setY(startYPosition - distanceYToSubtract);
    child.setX(startXPosition - distanceXToSubtract);

    CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
    lp.width = (int) (startHeight - heightToSubtract);
    lp.height = (int) (startHeight - heightToSubtract);
    child.setLayoutParams(lp);
    return true;
}
 
开发者ID:FarshidABZ,项目名称:CoordinatorBehavior,代码行数:25,代码来源:ImageBehavior.java

示例6: addHiddenViews

import android.view.View; //导入方法依赖的package包/类
private void addHiddenViews() {
    for (int indexHiddenView : indexHiddenViews) {
        View hiddenView = animationLayout.getChildAt(indexHiddenView);
        hiddenView.setX(mainView.getX());
        hiddenView.setY(mainView.getY());
        animationController.addHiddenView(hiddenView);
    }
    animationController.generateHandler();
}
 
开发者ID:AppliKey,项目名称:Sunstrike,代码行数:10,代码来源:SunStrike.java

示例7: actionMove

import android.view.View; //导入方法依赖的package包/类
private boolean actionMove(MotionEvent event, Banner banner) {
    View bannerView = banner.view;
    mXMove = event.getRawX();
    int scrolledX = (int) (mXLastMove - mXMove);
    Banner bannerNew = looper.changeRunningManByScrollDirection(scrolledX);
    if(banner.position!=bannerNew.position){
        banner = bannerNew;
        bannerView = banner.view;
        mXDownView = bannerView.getX();
    }

    LogUtil.d(TAG, "onTouchEvent scrolledX:"+scrolledX + " bannerView.getScrollX():"+bannerView.getScrollX()+" banner.exitEndX:"+banner.exitEndX+" banner.enterEndX:"+banner.enterEndX + " bannerView.getWidth():"+bannerView.getWidth());
    LogUtil.d(TAG, "onTouchEvent bannerView.getTranslationX():"+bannerView.getTranslationX()+" bannerView.getX():"+bannerView.getX());
    if (bannerView.getX()-scrolledX < banner.exitEndX) { //左滑到底
        bannerView.setX(banner.exitEndX);
        edgeGlowOnPull(event);
        return true;
    } else if (bannerView.getX()-scrolledX > banner.enterEndX ) { //右滑到底
        bannerView.setX(banner.enterEndX);
        edgeGlowOnPull(event);
        return true;
    }

    LogUtil.d(TAG, "滑动 bannerView.offsetLeftAndRight:"+-scrolledX);
    bannerView.offsetLeftAndRight(-scrolledX);
    LogUtil.d(TAG1,  " bannerView.getScrollX():"+bannerView.getScrollX()+" bannerView.getTranslationX():"+bannerView.getTranslationX()+" bannerView.getX():"+bannerView.getX()+" bannerView.getLeft():"+bannerView.getLeft());

    mXLastMove = mXMove;
    return false;
}
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:31,代码来源:BannerLayout.java

示例8: render

import android.view.View; //导入方法依赖的package包/类
@Override
public void render(CoachmarkViewLayout layout, View actionDescription, View actionArrow) {

    RectF circleRectangle = layout.calcCircleRectF();

    actionDescription.setX(circleRectangle.centerX() - (actionDescription.getWidth() / 2));
    actionDescription.setY(circleRectangle.top - actionArrow.getHeight() - actionDescription.getHeight());

    actionArrow.setRotation(90);
    actionArrow.setX(circleRectangle.centerX() - (actionArrow.getWidth() / 2));
    actionArrow.setY(circleRectangle.top - actionArrow.getHeight());
}
 
开发者ID:Kaufland,项目名称:andcoachmark,代码行数:13,代码来源:TopOfCircleActionDescriptionRenderer.java

示例9: animatePeek

import android.view.View; //导入方法依赖的package包/类
/**
 * Starts a peek animation to add a specific tab.
 *
 * @param item
 *         The item, which corresponds to the tab, which should be added, as an instance of the
 *         class {@link AbstractItem}. The item may not be null
 * @param duration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param interpolator
 *         The interpolator, which should be used by the animation, as an instance of the type
 *         {@link Interpolator}. The interpolator may not be null
 * @param peekPosition
 *         The position on the dragging axis, the tab should be moved to, in pixels as a {@link
 *         Float} value
 * @param peekAnimation
 *         The peek animation, which has been used to add the tab, as an instance of the class
 *         {@link PeekAnimation}. The peek animation may not be null
 */
private void animatePeek(@NonNull final AbstractItem item, final long duration,
                         @NonNull final Interpolator interpolator, final float peekPosition,
                         @NonNull final PeekAnimation peekAnimation) {
    PhoneTabViewHolder viewHolder = (PhoneTabViewHolder) ((TabItem) item).getViewHolder();
    viewHolder.closeButton.setVisibility(View.GONE);
    View view = item.getView();
    float x = peekAnimation.getX();
    float y = peekAnimation.getY() + tabTitleContainerHeight;
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setAlpha(1f);
    getArithmetics().setPivot(Axis.X_AXIS, item, x);
    getArithmetics().setPivot(Axis.Y_AXIS, item, y);
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 0);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 0);
    ViewPropertyAnimator animation = view.animate();
    animation.setInterpolator(interpolator);
    animation.setListener(
            new AnimationListenerWrapper(createPeekAnimationListener(item, peekAnimation)));
    animation.setStartDelay(0);
    animation.setDuration(duration);
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, item, peekPosition, true);
    animation.start();
    int selectedTabIndex = getModel().getSelectedTabIndex();
    TabItem selectedItem = TabItem.create(getModel(), tabViewRecycler, selectedTabIndex);
    tabViewRecycler.inflate(selectedItem);
    selectedItem.getTag().setPosition(0);
    PhoneTabViewHolder selectedTabViewHolder =
            (PhoneTabViewHolder) selectedItem.getViewHolder();
    selectedTabViewHolder.closeButton.setVisibility(View.GONE);
    animateShowSwitcher(selectedItem, duration, interpolator,
            createZoomOutAnimationListener(selectedItem, peekAnimation));
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:55,代码来源:PhoneTabSwitcherLayout.java

示例10: setX

import android.view.View; //导入方法依赖的package包/类
public static void setX(View view, float x) {
    if (View10.NEED_PROXY) {
        View10.wrap(view).setX(x);
    } else {
        view.setX(x);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:8,代码来源:ViewProxy.java

示例11: setX

import android.view.View; //导入方法依赖的package包/类
static void setX(View view, float x) {
    view.setX(x);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ViewHelper.java

示例12: toEndState

import android.view.View; //导入方法依赖的package包/类
@Override
protected void toEndState(View view) {
    view.setX(toX);
    view.setY(toY);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) view.setZ(toZ);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:WoWoPosition3DAnimation.java

示例13: setProperty

import android.view.View; //导入方法依赖的package包/类
@Override
protected void setProperty(View view, float[] propertyValues) {
  view.setX(propertyValues[0] - 0.5f * view.getWidth());
  view.setY(propertyValues[1] - 0.5f * view.getHeight());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:6,代码来源:PositionAnimationPairPropertyUpdater.java

示例14: animateShowSwitcher

import android.view.View; //导入方法依赖的package包/类
/**
 * Animates the position and size of a specific tab in order to show the tab switcher.
 *
 * @param item
 *         The item, which corresponds to the tab, which should be animated, as an instance of
 *         the class {@link AbstractItem}. The item may not be null
 * @param duration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param interpolator
 *         The interpolator, which should be used by the animation, as an instance of the type
 *         {@link Interpolator}. The interpolator may not be null
 * @param listener
 *         The listener, which should be notified about the animation's progress, as an instance
 *         of the type {@link AnimatorListener} or null, if no listener should be notified
 */
private void animateShowSwitcher(@NonNull final AbstractItem item, final long duration,
                                 @NonNull final Interpolator interpolator,
                                 @Nullable final AnimatorListener listener) {
    View view = item.getView();
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1);
    getArithmetics().setPivot(Axis.DRAGGING_AXIS, item,
            getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE));
    getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
            getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE));
    float scale = getArithmetics().getScale(item, true);
    int selectedTabIndex = getModel().getSelectedTabIndex();

    if (item.getIndex() < selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, item,
                getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS));
    } else if (item.getIndex() > selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, item,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin);
    }

    if (tabViewBottomMargin == -1) {
        tabViewBottomMargin = calculateBottomMargin(item);
    }

    animateBottomMargin(view, tabViewBottomMargin, duration, 0);
    ViewPropertyAnimator animation = view.animate();
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setListener(new AnimationListenerWrapper(listener));
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, scale);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, scale);
    getArithmetics()
            .animatePosition(Axis.DRAGGING_AXIS, animation, item, item.getTag().getPosition(),
                    true);
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, item, 0, true);
    animation.setStartDelay(0);
    animation.start();
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:59,代码来源:PhoneTabSwitcherLayout.java

示例15: 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


注:本文中的android.view.View.setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。