Java Code Examples for android.widget.TextView#setTranslationX()

The following examples show how to use android.widget.TextView#setTranslationX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupSettingsCoordinatorLayoutBehavior.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private void updateNamePosition(@NonNull CoordinatorLayout parent, float factor) {
  TextView child  = (TextView) groupNameRef.require(parent);
  View     target = groupNameTargetRef.require(parent);

  targetRect.set(target.getLeft(), target.getTop(), target.getRight(), target.getBottom());
  childRect.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());

  if (child.getMaxWidth() != targetRect.width()) {
    child.setMaxWidth(targetRect.width());
  }

  float deltaTop   = targetRect.top - childRect.top;
  float deltaStart = getStart(parent, targetRect) - getStart(parent, childRect);

  float yTranslation = deltaTop * factor;
  float xTranslation = deltaStart * factor;

  child.setTranslationY(yTranslation);
  child.setTranslationX(xTranslation);
}
 
Example 2
Source File: ActivityAnimSegment.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
public void drawFrame(Activity painter, float segmentProgress) {
    TextView textView = (TextView) painter.findViewById(android.R.id.content).findViewWithTag("text");
    textView.setRotation(segmentProgress * 7200);

    int maxX = (int) (mViewportRect.width() / 2);
    int maxY = (int) (mViewportRect.height() / 2);

    if (!(mTransX > -maxX && mTransX < maxX)) {
        mStepX = getRanStep();
        mStepX = mTransX > 0 ? -mStepX : mStepX;
    }
    mTransX += mStepX;

    if (!(mTransY > -maxY && mTransY < maxY)) {
        mStepY = getRanStep();
        mStepY = mTransY > 0 ? -mStepY : mStepY;
    }
    mTransY += mStepY;

    textView.setTranslationX(mTransX);
    textView.setTranslationY(mTransY);
}
 
Example 3
Source File: PasscodeView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (dotRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(dotRunnable);
        dotRunnable = null;
    }
    if (currentAnimation != null) {
        currentAnimation.cancel();
        currentAnimation = null;
    }

    for (int a = 0; a < 4; a++) {
        if (a < stringBuilder.length()) {
            TextView textView = characterTextViews.get(a);
            textView.setAlpha(0);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));

            textView = dotTextViews.get(a);
            textView.setAlpha(1);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));
        } else {
            characterTextViews.get(a).setAlpha(0);
            dotTextViews.get(a).setAlpha(0);
        }
    }
    super.onLayout(changed, left, top, right, bottom);
}
 
Example 4
Source File: TitleChanger.java    From monthweekmaterialcalendarview with Apache License 2.0 5 votes vote down vote up
private void doTranslation(final TextView title, final int translate) {
    if (orientation == MaterialCalendarView.HORIZONTAL) {
        title.setTranslationX(translate);
    } else {
        title.setTranslationY(translate);
    }
}
 
Example 5
Source File: PasscodeView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (dotRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(dotRunnable);
        dotRunnable = null;
    }
    if (currentAnimation != null) {
        currentAnimation.cancel();
        currentAnimation = null;
    }

    for (int a = 0; a < 4; a++) {
        if (a < stringBuilder.length()) {
            TextView textView = characterTextViews.get(a);
            textView.setAlpha(0);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));

            textView = dotTextViews.get(a);
            textView.setAlpha(1);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));
        } else {
            characterTextViews.get(a).setAlpha(0);
            dotTextViews.get(a).setAlpha(0);
        }
    }
    super.onLayout(changed, left, top, right, bottom);
}
 
Example 6
Source File: RxPopupViewManager.java    From RxTools-master with Apache License 2.0 5 votes vote down vote up
private void moveTipToCorrectPosition(TextView tipView, Point p) {
    RxCoordinates tipViewRxCoordinates = new RxCoordinates(tipView);
    int translationX = p.x - tipViewRxCoordinates.left;
    int translationY = p.y - tipViewRxCoordinates.top;
    if (!RxPopupViewTool.isRtl()) tipView.setTranslationX(translationX);
    else tipView.setTranslationX(-translationX);
    tipView.setTranslationY(translationY);
}
 
Example 7
Source File: TitleChanger.java    From calendarview2 with MIT License 5 votes vote down vote up
private void doTranslation(final TextView title, final int translate) {
    if (orientation == CalendarView2.HORIZONTAL) {
        title.setTranslationX(translate);
    } else {
        title.setTranslationY(translate);
    }
}
 
Example 8
Source File: IntroPageTransformer.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
private void transformOne(View page, float position) {
    int pageWidth = page.getWidth();
    float pageWidthTimesPosition = pageWidth * position;
    float absPosition = Math.abs(position);
    ImageView backgroundImage = (ImageView) page.findViewById(R.id.image_view);
    TextView titleView = (TextView) page.findViewById(R.id.title_text);
    TextView descriptionView = (TextView) page.findViewById(R.id.description);
    View indicatorView1 = page.findViewById(R.id.indicator_view_1);
    View indicatorView2 = page.findViewById(R.id.indicator_view_2);
    View indicatorView3 = page.findViewById(R.id.indicator_view_3);

    if (position <= -1.0f || position >= 1.0f) {
    } else if (position == 0.0f) {
    } else {
        if (pageWidthTimesPosition > 1) {
            backgroundImage.setScaleY(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
        } else if (pageWidthTimesPosition < 1) {
            backgroundImage.setScaleY(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
        }

        titleView.setTranslationX(pageWidthTimesPosition * X_MIN_VEL);
        descriptionView.setTranslationX(pageWidthTimesPosition * X_MAX_VEL);

        indicatorView1.setTranslationX(-pageWidthTimesPosition * 1f);
        indicatorView2.setAlpha(1.0f - (5 * absPosition));
        indicatorView3.setAlpha(1.0f - (5 * absPosition));
    }
}
 
Example 9
Source File: IntroPageTransformer.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
private void transformTwo(View page, float position) {
    int pageWidth = page.getWidth();
    float pageWidthTimesPosition = pageWidth * position;
    float absPosition = Math.abs(position);
    ImageView backgroundImage = (ImageView) page.findViewById(R.id.image_view);
    TextView titleView = (TextView) page.findViewById(R.id.title_text);
    TextView descriptionView = (TextView) page.findViewById(R.id.description);
    View indicatorView1 = page.findViewById(R.id.indicator_view_1);
    View indicatorView2 = page.findViewById(R.id.indicator_view_2);
    View indicatorView3 = page.findViewById(R.id.indicator_view_3);

    if (position <= -1.0f || position >= 1.0f) {
    } else if (position == 0.0f) {
    } else {
        if (pageWidthTimesPosition > 1) {
            backgroundImage.setScaleY(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
        } else if (pageWidthTimesPosition < 1) {
            backgroundImage.setScaleY(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
        }

        titleView.setTranslationX(pageWidthTimesPosition * X_MIN_VEL);
        descriptionView.setTranslationX(pageWidthTimesPosition * X_MAX_VEL);

        indicatorView2.setTranslationX(-pageWidthTimesPosition * 1f);
        indicatorView1.setAlpha(1.0f - (5 * absPosition));
        indicatorView3.setAlpha(1.0f - (5 * absPosition));
    }
}
 
Example 10
Source File: IntroPageTransformer.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
private void transformThree(View page, float position) {
    int pageWidth = page.getWidth();
    float pageWidthTimesPosition = pageWidth * position;
    float absPosition = Math.abs(position);
    ImageView backgroundImage = (ImageView) page.findViewById(R.id.image_view);
    TextView titleView = (TextView) page.findViewById(R.id.title_text);
    TextView descriptionView = (TextView) page.findViewById(R.id.description);
    View indicatorView1 = page.findViewById(R.id.indicator_view_1);
    View indicatorView2 = page.findViewById(R.id.indicator_view_2);
    View indicatorView3 = page.findViewById(R.id.indicator_view_3);

    if (position <= -1.0f || position >= 1.0f) {
    } else if (position == 0.0f) {
    } else {
        if (pageWidthTimesPosition > 1) {
            backgroundImage.setScaleY(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 + (pageWidthTimesPosition * SCALE_Y_FACTOR));
        } else if (pageWidthTimesPosition < 1) {
            backgroundImage.setScaleY(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
            backgroundImage.setScaleX(1 - (pageWidthTimesPosition * SCALE_Y_FACTOR));
        }

        titleView.setTranslationX(pageWidthTimesPosition * X_MIN_VEL);
        descriptionView.setTranslationX(pageWidthTimesPosition * X_MAX_VEL);

        indicatorView3.setTranslationX(-pageWidthTimesPosition * 1f);
        indicatorView1.setAlpha(1f - (5 * absPosition));
        indicatorView2.setAlpha(1f - (5 * absPosition));
    }
}
 
Example 11
Source File: TabSwitcherOpenButton.java    From Cornowser with MIT License 5 votes vote down vote up
public void setTabCount(int count) {
    String tabCount = String.valueOf(count);
    TextView t = ((TextView)getChildAt(1));
    ImageView img = ((ImageView)getChildAt(0));
    t.setText(tabCount);
    t.setTranslationX( Math.round( (img.getWidth() / 2) - (t.getWidth() / 2) ) );
}
 
Example 12
Source File: TitleChanger.java    From material-calendarview with MIT License 5 votes vote down vote up
private void doTranslation(final TextView title, final int translate) {
  if (orientation == MaterialCalendarView.HORIZONTAL) {
    title.setTranslationX(translate);
  } else {
    title.setTranslationY(translate);
  }
}
 
Example 13
Source File: PasscodeView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (dotRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(dotRunnable);
        dotRunnable = null;
    }
    if (currentAnimation != null) {
        currentAnimation.cancel();
        currentAnimation = null;
    }

    for (int a = 0; a < 4; a++) {
        if (a < stringBuilder.length()) {
            TextView textView = characterTextViews.get(a);
            textView.setAlpha(0);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));

            textView = dotTextViews.get(a);
            textView.setAlpha(1);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));
        } else {
            characterTextViews.get(a).setAlpha(0);
            dotTextViews.get(a).setAlpha(0);
        }
    }
    super.onLayout(changed, left, top, right, bottom);
}
 
Example 14
Source File: PasscodeView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (dotRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(dotRunnable);
        dotRunnable = null;
    }
    if (currentAnimation != null) {
        currentAnimation.cancel();
        currentAnimation = null;
    }

    for (int a = 0; a < 4; a++) {
        if (a < stringBuilder.length()) {
            TextView textView = characterTextViews.get(a);
            textView.setAlpha(0);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));

            textView = dotTextViews.get(a);
            textView.setAlpha(1);
            textView.setScaleX(1);
            textView.setScaleY(1);
            textView.setTranslationY(0);
            textView.setTranslationX(getXForTextView(a));
        } else {
            characterTextViews.get(a).setAlpha(0);
            dotTextViews.get(a).setAlpha(0);
        }
    }
    super.onLayout(changed, left, top, right, bottom);
}