Java Code Examples for android.view.View.setY()

The following are Jave code examples for showing how to use setY() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: VirtualHook   File: CardStackAdapter.java   Source Code and License Vote up 9 votes
void addView(final int position) {
	View root = createView(position, mParent);
	root.setOnTouchListener(this);
	root.setTag(R.id.cardstack_internal_position_tag, position);
	root.setLayerType(View.LAYER_TYPE_HARDWARE, null);

	mCardPaddingInternal = root.getPaddingTop();

	FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullCardHeight);
	root.setLayoutParams(lp);
	if (mShowInitAnimation) {
		root.setY(getCardFinalY(position));
		setScreenTouchable(false);
	} else {
		root.setY(getCardOriginalY(position) - mParentPaddingTop);
		setScreenTouchable(true);
	}

	mCardViews[position] = root;

	mParent.addView(root);
}
 
Example 2
Project: ChromeLikeTabSwitcher   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 7 votes
/**
 * 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);
        }

    };
}
 
Example 3
Project: ChromeLikeTabSwitcher   File: PhoneArithmetics.java   Source Code and License Vote up 7 votes
@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 (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
        Toolbar[] toolbars = getTabSwitcher().getToolbars();
        view.setY((getTabSwitcher().areToolbarsShown() && getTabSwitcher().isSwitcherShown() &&
                toolbars != null ?
                toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].getHeight() - tabInset : 0) +
                getTabSwitcherPadding(axis, Gravity.START) + position);
    } else {
        FrameLayout.LayoutParams layoutParams =
                (FrameLayout.LayoutParams) view.getLayoutParams();
        view.setX(position + layoutParams.leftMargin + getTabSwitcher().getPaddingLeft() / 2f -
                getTabSwitcher().getPaddingRight() / 2f -
                (getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE &&
                        getTabSwitcher().isSwitcherShown() ?
                        stackedTabCount * stackedTabSpacing / 2f : 0));
    }
}
 
Example 4
Project: simple-keyboard   File: MoreKeysKeyboardView.java   Source Code and License Vote up 7 votes
@Override
public void showMoreKeysPanel(final View parentView, final Controller controller,
        final int pointX, final int pointY, final KeyboardActionListener listener) {
    mController = controller;
    mListener = listener;
    final View container = getContainerView();
    // The coordinates of panel's left-top corner in parentView's coordinate system.
    // We need to consider background drawable paddings.
    final int x = pointX - getDefaultCoordX() - container.getPaddingLeft() - getPaddingLeft();
    final int y = pointY - container.getMeasuredHeight() + container.getPaddingBottom()
            + getPaddingBottom();

    parentView.getLocationInWindow(mCoordinates);
    // Ensure the horizontal position of the panel does not extend past the parentView edges.
    final int maxX = parentView.getMeasuredWidth() - container.getMeasuredWidth();
    final int panelX = Math.max(0, Math.min(maxX, x)) + CoordinateUtils.x(mCoordinates);
    final int panelY = y + CoordinateUtils.y(mCoordinates);
    container.setX(panelX);
    container.setY(panelY);

    mOriginX = x + container.getPaddingLeft();
    mOriginY = y + container.getPaddingTop();
    controller.onShowMoreKeysPanel(this);
}
 
Example 5
Project: VirtualHook   File: CardStackAdapter.java   Source Code and License Vote up 7 votes
private void moveCards(int positionOfCardToMove, float diff) {
	if (diff < 0 || positionOfCardToMove < 0 || positionOfCardToMove >= getCount())
		return;
	for (int i = positionOfCardToMove; i < getCount(); i++) {
		final View child = mCardViews[i];
		float diffCard = diff / scaleFactorForElasticEffect;
		if (mParallaxEnabled) {
			if (mParallaxScale > 0) {
				diffCard = diffCard * (mParallaxScale / 3) * (getCount() + 1 - i);
			} else {
				int scale = mParallaxScale * -1;
				diffCard = diffCard * (i * (scale / 3) + 1);
			}
		} else
			diffCard = diffCard * (getCount() * 2 + 1);
		child.setY(getCardOriginalY(i) + diffCard);
	}
}
 
Example 6
Project: ChromeLikeTabSwitcher   File: TabletArithmetics.java   Source Code and License Vote up 7 votes
@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);
    }
}
 
Example 7
Project: GitHub   File: Instrument.java   Source Code and License Vote up 6 votes
public void slidingToY(View view ,float y){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setY(y);
    }else{
        ViewHelper.setY(view, y);
    }
}
 
Example 8
Project: andcoachmark   File: TopOrBottomDescriptionRenderer.java   Source Code and License Vote up 6 votes
@Override
public void render(CoachmarkViewLayout layout, View description) {

    RectF circle = layout.calcCircleRectF();
    RectF screenRectangle = layout.calcScreenRectF();

    if(circle.centerY() > screenRectangle.height() / 2){
        description.setY(description.getContext().getResources().getDimension(R.dimen.description_padding));
    }else{
        description.setY(screenRectangle.height() - description.getContext().getResources().getDimension(R.dimen.description_padding) - description.getHeight());
    }

}
 
Example 9
Project: boohee_v5.6   File: ViewPropertyAnimatorHC.java   Source Code and License Vote up 6 votes
private void setValue(int propertyConstant, float value) {
    View v = (View) this.mView.get();
    if (v != null) {
        switch (propertyConstant) {
            case 1:
                v.setTranslationX(value);
                return;
            case 2:
                v.setTranslationY(value);
                return;
            case 4:
                v.setScaleX(value);
                return;
            case 8:
                v.setScaleY(value);
                return;
            case 16:
                v.setRotation(value);
                return;
            case 32:
                v.setRotationX(value);
                return;
            case 64:
                v.setRotationY(value);
                return;
            case 128:
                v.setX(value);
                return;
            case 256:
                v.setY(value);
                return;
            case 512:
                v.setAlpha(value);
                return;
            default:
                return;
        }
    }
}
 
Example 10
Project: BehaviorDemo   File: MainTabBehavior.java   Source Code and License Vote up 6 votes
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    float tabScrollY = dependency.getTranslationY() / getHeaderOffset() * (dependency.getHeight() - getTitleHeight());
    float y = dependency.getHeight() - tabScrollY;
    child.setY(y);
    return true;
}
 
Example 11
Project: floatingMenu   File: FloatingMenuAnimationHandler.java   Source Code and License Vote up 6 votes
private void resetSubButton(Point center, SubButton subButton, View subButtonView) {
    if (subButton != null) {
        int floatingMenuButtonWidth = floatingMenuButton.getWidth();
        int floatingMenuButtonHeight = floatingMenuButton.getHeight();
        int xResetPos = center.x + floatingMenuButtonWidth / 2;
        int yResetPos = center.y - floatingMenuButtonHeight / 2;
        subButtonView.setX(xResetPos);
        subButtonView.setY(yResetPos);
        subButtonView.setScaleX(0);
        subButtonView.setScaleY(0);
        subButton.setX(xResetPos);
        subButton.setY(yResetPos);
        subButton.setAlpha(0);
    }
}
 
Example 12
Project: circle-menu-android   File: CircleMenuView.java   Source Code and License Vote up 6 votes
private void offsetAndScaleButtons(float centerX, float centerY, float angleStep, float offset, float scale) {
    for (int i = 0, cnt = mButtons.size(); i < cnt; i++) {
        final float angle = angleStep * i - 90;
        final float x = (float) Math.cos(Math.toRadians(angle)) * offset;
        final float y = (float) Math.sin(Math.toRadians(angle)) * offset;

        final View button = mButtons.get(i);
        button.setX(centerX + x);
        button.setY(centerY + y);
        button.setScaleX(1.0f * scale);
        button.setScaleY(1.0f * scale);
    }
}
 
Example 13
Project: airgram   File: ViewProxy.java   Source Code and License Vote up 6 votes
public static void setY(View view, float y) {
    if (View10.NEED_PROXY) {
        View10.wrap(view).setY(y);
    } else {
        view.setY(y);
    }
}
 
Example 14
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 6 votes
/**
 * Creates and returns an animation listener, which allows to inflate or remove the views, which
 * are used to visualize tabs, when an animation, which is used to hide the tab switcher,
 * has been finished.
 *
 * @return The animation listener, which has been created, as an instance of the type {@link
 * AnimatorListener}. The listener may not be null
 */
@NonNull
private AnimatorListener createHideSwitcherAnimationListener() {
    return new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animation) {
            super.onAnimationEnd(animation);
            AbstractTabItemIterator iterator =
                    new TabItemIterator.Builder(getTabSwitcher(), viewRecycler).create();
            TabItem tabItem;

            while ((tabItem = iterator.next()) != null) {
                if (tabItem.getTab() == getModel().getSelectedTab()) {
                    Pair<View, Boolean> pair = viewRecycler.inflate(tabItem);
                    View view = pair.first;
                    FrameLayout.LayoutParams layoutParams =
                            (FrameLayout.LayoutParams) view.getLayoutParams();
                    view.setAlpha(1f);
                    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
                    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
                    view.setX(layoutParams.leftMargin);
                    view.setY(layoutParams.topMargin);
                } else {
                    viewRecycler.remove(tabItem);
                }
            }

            viewRecycler.clearCache();
            recyclerAdapter.clearCachedPreviews();
            tabViewBottomMargin = -1;
        }

    };
}
 
Example 15
Project: SwipeDeckRelease   File: SwipeDeck.java   Source Code and License Vote up 6 votes
private void addNextView() {
    if (adapterIndex < mAdapter.getCount()) {
        View newBottomChild = mAdapter.getView(adapterIndex, null, this);
        newBottomChild.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        //todo: i'm setting the card to invisible initially and making it visible when i animate
        //later
        newBottomChild.setAlpha(0);
        newBottomChild.setY(getPaddingTop());
        final long viewId = mAdapter.getItemId(adapterIndex);

        CardContainer card = new CardContainer(newBottomChild, this, new CardContainerCallback(viewId));

        card.setPositionWithinAdapter(adapterIndex);

        if (leftImageResource != 0) {
            card.setLeftImageResource(leftImageResource);
        }
        if (rightImageResource != 0) {
            card.setRightImageResource(rightImageResource);
        }

        card.setId(viewId);

        deck.addBack(card);
        adapterIndex++;
    }
}
 
Example 16
Project: BehaviorDemo   File: MainTitleBehavior.java   Source Code and License Vote up 5 votes
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    float y = -(1 - dependency.getTranslationY() / getHeaderOffset()) * getTitleHeight();
    child.setY(y);
    return true;
}
 
Example 17
Project: NeoTerm   File: PhoneTabSwitcherLayout.java   Source Code and License Vote up 5 votes
/**
 * Animates the position and size of a specific tab in order to show the tab switcher.
 *
 * @param tabItem
 *         The tab item, which should be animated, as an instance of the class {@link TabItem}.
 *         The tab 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 TabItem tabItem, final long duration,
                                 @NonNull final Interpolator interpolator,
                                 @Nullable final AnimatorListener listener) {
    View view = tabItem.getView();
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
    getArithmetics().setPivot(Axis.DRAGGING_AXIS, view,
            getArithmetics().getPivot(Axis.DRAGGING_AXIS, view, DragState.NONE));
    getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, view,
            getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, view, DragState.NONE));
    float scale = getArithmetics().getScale(view, true);
    int selectedTabIndex = getModel().getSelectedTabIndex();

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

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

    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, view,
            tabItem.getTag().getPosition(), true);
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, view, 0, true);
    animation.setStartDelay(0);
    animation.start();
}
 
Example 18
Project: BehaviorDemo   File: XiamiTitleBehavior.java   Source Code and License Vote up 5 votes
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
    float y = -(1 - dependency.getTranslationY() / getHeaderOffset()) * getTitleHeight();
    child.setY(y);
    return true;
}
 
Example 19
Project: letv   File: ViewCompatHC.java   Source Code and License Vote up 5 votes
public static void setY(View view, float value) {
    view.setY(value);
}
 
Example 20
Project: andswipeframework   File: LayoutCache.java   Source Code and License Vote up 4 votes
public void restoreOnLayout(){

        for (View child : mLayoutCache.keySet()){

            PointF restorePoint = mLayoutCache.get(child);

            if(restorePoint != null){
                child.setX(restorePoint.x);
                child.setY(restorePoint.y);
            }

        }

    }