android.widget.TextView#setTranslationX ( )源码实例Demo

下面列出了android.widget.TextView#setTranslationX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
}
 
源代码2 项目: PhotoMovie   文件: ActivityAnimSegment.java
@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);
}
 
源代码3 项目: TelePlus-Android   文件: PasscodeView.java
@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);
}
 
private void doTranslation(final TextView title, final int translate) {
    if (orientation == MaterialCalendarView.HORIZONTAL) {
        title.setTranslationX(translate);
    } else {
        title.setTranslationY(translate);
    }
}
 
源代码5 项目: TelePlus-Android   文件: PasscodeView.java
@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);
}
 
源代码6 项目: RxTools-master   文件: RxPopupViewManager.java
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);
}
 
源代码7 项目: calendarview2   文件: TitleChanger.java
private void doTranslation(final TextView title, final int translate) {
    if (orientation == CalendarView2.HORIZONTAL) {
        title.setTranslationX(translate);
    } else {
        title.setTranslationY(translate);
    }
}
 
源代码8 项目: Saude-no-Mapa   文件: IntroPageTransformer.java
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));
    }
}
 
源代码9 项目: Saude-no-Mapa   文件: IntroPageTransformer.java
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));
    }
}
 
源代码10 项目: Saude-no-Mapa   文件: IntroPageTransformer.java
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));
    }
}
 
源代码11 项目: Cornowser   文件: TabSwitcherOpenButton.java
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) ) );
}
 
源代码12 项目: material-calendarview   文件: TitleChanger.java
private void doTranslation(final TextView title, final int translate) {
  if (orientation == MaterialCalendarView.HORIZONTAL) {
    title.setTranslationX(translate);
  } else {
    title.setTranslationY(translate);
  }
}
 
源代码13 项目: Telegram-FOSS   文件: PasscodeView.java
@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);
}
 
源代码14 项目: Telegram   文件: PasscodeView.java
@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);
}
 
 方法所在类
 同类方法