下面列出了android.widget.TextView#setScaleY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private TextView createHeaderItem(int position, String headerText) {
TextView header = new TextView(getContext());
LayoutParams linearParams = new LayoutParams(headerWidth / headerPerView, LayoutParams.WRAP_CONTENT);
header.setLayoutParams(linearParams);
header.setScaleX(textViewAttr.getHvMinScale());
header.setScaleY(textViewAttr.getHvMinScale());
header.setAlpha(textViewAttr.getHvTextAlpha());
header.setTextColor(textViewAttr.getHvTextColor());
header.setPadding(0, (int) textViewAttr.getHvPadding(), 0, (int) textViewAttr.getHvPadding());
header.setMaxLines(1);
header.setGravity(Gravity.CENTER);
header.setEllipsize(TextUtils.TruncateAt.END);
header.setText(headerText);
header.setTextSize(TypedValue.COMPLEX_UNIT_PX, textViewAttr.getHvTextSize());
textViews[position] = header;
return header;
}
/**
* @param animate whether to animate the change
* @return this, to allow builder pattern
*/
public T show(boolean animate) {
mIsHidden = false;
if (isWeakReferenceValid()) {
TextView textView = mTextViewRef.get();
if (animate) {
textView.setScaleX(0);
textView.setScaleY(0);
textView.setVisibility(View.VISIBLE);
ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
animatorCompat.cancel();
animatorCompat.setDuration(mAnimationDuration);
animatorCompat.scaleX(1).scaleY(1);
animatorCompat.setListener(null);
animatorCompat.start();
} else {
textView.setScaleX(1);
textView.setScaleY(1);
textView.setVisibility(View.VISIBLE);
}
}
return getSubInstance();
}
/**
* Moves the finger trace associated with the specified pointer id to a new location in the
* view.
*
* @param pointerId the pointer id of the finger trace to move
* @param point the new location of the finger trace
*/
private void moveFingerTrace(int pointerId, float x, float y) {
TextView fingerTraceView = mFingerTraceViews[pointerId];
// Cancel any current animations on the view and bring it back to full opacity.
fingerTraceView.animate().cancel();
fingerTraceView.setScaleX(1.0f);
fingerTraceView.setScaleY(1.0f);
fingerTraceView.setAlpha(1);
// Reposition the finger trace by updating the layout margins of its view.
RelativeLayout.LayoutParams lp =
(RelativeLayout.LayoutParams) fingerTraceView.getLayoutParams();
int viewX = (int) (x / mTouchpadHardwareWidth * getWidth());
int viewY = (int) (y / mTouchpadHardwareHeight * getHeight());
lp.leftMargin = viewX - FINGER_TRACE_SIZE / 2;
lp.topMargin = viewY - FINGER_TRACE_SIZE / 2;
fingerTraceView.setLayoutParams(lp);
}
@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);
}
@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);
}
/**
* @param animate whether to animate the change
* @return this, to allow builder pattern
*/
public BadgeItem show(boolean animate) {
mIsHidden = false;
if (isWeakReferenceValid()) {
TextView textView = mTextViewRef.get();
if (animate) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
textView.setScaleX(0);
textView.setScaleY(0);
}
textView.setVisibility(View.VISIBLE);
ViewPropertyAnimatorCompat animatorCompat = ViewCompat.animate(textView);
animatorCompat.cancel();
animatorCompat.setDuration(mAnimationDuration);
animatorCompat.scaleX(1).scaleY(1);
animatorCompat.setListener(null);
animatorCompat.start();
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
textView.setScaleX(1);
textView.setScaleY(1);
}
textView.setVisibility(View.VISIBLE);
}
}
return this;
}
private void setTabSelect(int from, int to) {
if (from != -1) {
ViewGroup tabItemFrom = this.findViewWithTag(from);
ImageView preImg = (ImageView) tabItemFrom.getChildAt(0);
TextView preText = (TextView) tabItemFrom.getChildAt(1);
//pre_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
preImg.setColorFilter(COLOR_UNSELECT);
preText.setTextColor(COLOR_UNSELECT);
preText.setPivotX(preImg.getWidth() / 2);
preText.setScaleX(1.0f);
preText.setScaleY(1.0f);
}
ViewGroup tabItemTo = this.findViewWithTag(to);
ImageView toImg = (ImageView) tabItemTo.getChildAt(0);
TextView toText = (TextView) tabItemTo.getChildAt(1);
//to_text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
toImg.setImageResource(iconsUnselect[to]);
toImg.setColorFilter(COLOR_SELECT);
toText.setTextColor(COLOR_SELECT);
toText.setPivotX(toText.getWidth() / 2);
toText.setScaleX(1.08f);
toText.setScaleY(1.08f);
refreshDrawableState();
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, TextView child, View dependency) {
AppBarLayout appBarLayout = (AppBarLayout) dependency;
shouldInitProperties(child, appBarLayout);
int currentScroll = dependency.getBottom();
float percentage = (float) currentScroll / (float) mMaxScrollAppBar;
if (percentage < TOOLBAR_SCALE) {
percentage = TOOLBAR_SCALE;
}
child.setScaleY(percentage);
child.setScaleX(percentage);
return true;
}
@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);
}
@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 updateTextView(TextView textView, float scale, float alpha, int color) {
textView.setScaleX(scale);
textView.setScaleY(scale);
textView.setAlpha(alpha);
textView.setTextColor(color);
}