本文整理汇总了Java中android.widget.TextView.invalidate方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.invalidate方法的具体用法?Java TextView.invalidate怎么用?Java TextView.invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.invalidate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCursorDrawable
import android.widget.TextView; //导入方法依赖的package包/类
public static void setCursorDrawable(TextView v, int cursorDrawableRes) {
try {
if (sCursorDrawableRes == null) {
sCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
sCursorDrawableRes.setAccessible(true);
}
sCursorDrawableRes.set(v, cursorDrawableRes);
v.invalidate();
if (sEditor == null) {
sEditor = TextView.class.getDeclaredField("mEditor");
sEditor.setAccessible(true);
}
Object editor = sEditor.get(v);
if(editor != null){
if (sCursorDrawable == null) {
Class<?> clazz = editor.getClass();
sCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
sCursorDrawable.setAccessible(true);
}
Drawable cursorDrawable = v.getContext().getResources().getDrawable(cursorDrawableRes);
sCursorDrawable.set(editor, cursorDrawable);
}
} catch (Exception ignored) {
}
}
示例2: setAlignment
import android.widget.TextView; //导入方法依赖的package包/类
/**
* TextView alignment setter.
*
* @param alignment one of {@link Component#ALIGNMENT_NORMAL},
* {@link Component#ALIGNMENT_CENTER} or
* {@link Component#ALIGNMENT_OPPOSITE}
* @param centerVertically whether the text should be centered vertically
*/
public static void setAlignment(TextView textview, int alignment, boolean centerVertically) {
int horizontalGravity;
switch (alignment) {
default:
throw new IllegalArgumentException();
case Component.ALIGNMENT_NORMAL:
horizontalGravity = Gravity.LEFT;
break;
case Component.ALIGNMENT_CENTER:
horizontalGravity = Gravity.CENTER_HORIZONTAL;
break;
case Component.ALIGNMENT_OPPOSITE:
horizontalGravity = Gravity.RIGHT;
break;
}
int verticalGravity = centerVertically ? Gravity.CENTER_VERTICAL : Gravity.TOP;
textview.setGravity(horizontalGravity | verticalGravity);
textview.invalidate();
}
示例3: setGradient
import android.widget.TextView; //导入方法依赖的package包/类
public static void setGradient(TextView textView, final int[] colorBoxes, final float[] position, final GradientAngle gradientAngle) {
AngleCoordinate ac = AngleCoordinate.getAngleCoordinate(gradientAngle, textView.getWidth(), textView.getHeight());
LinearGradient linearGradient = new LinearGradient(ac.x1, ac.y1, ac.x2, ac.y2,
colorBoxes,
position,
Shader.TileMode.REPEAT);
textView.invalidate();
textView.getPaint().setShader(linearGradient);
}
示例4: onResourceReady
import android.widget.TextView; //导入方法依赖的package包/类
@Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
if (container != null && container.get() != null) {
TextView textView = container.get();
float width;
float height;
if (resource.getIntrinsicWidth() >= this.width) {
float downScale = (float) resource.getIntrinsicWidth() / this.width;
width = (float) (resource.getIntrinsicWidth() / downScale / 1.3);
height = (float) (resource.getIntrinsicHeight() / downScale / 1.3);
} else {
float multiplier = (float) this.width / resource.getIntrinsicWidth();
width = (float) resource.getIntrinsicWidth() * multiplier;
height = (float) resource.getIntrinsicHeight() * multiplier;
}
Rect rect = new Rect(0, 0, Math.round(width), Math.round(height));
resource.setBounds(rect);
urlDrawable.setBounds(rect);
urlDrawable.setDrawable(resource);
if (resource.isAnimated() && !PrefGetter.isGistDisabled()) {
urlDrawable.setCallback((Drawable.Callback) textView.getTag(R.id.drawable_callback));
resource.setLoopCount(GlideDrawable.LOOP_FOREVER);
resource.start();
}
textView.setText(textView.getText());
textView.invalidate();
}
}
示例5: setMessage
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 给Dialog设置提示信息
*
* @param message
*/
public void setMessage(CharSequence message) {
if (message != null && message.length() > 0) {
findViewById(R.id.message).setVisibility(View.VISIBLE);
TextView txt = (TextView) findViewById(R.id.message);
txt.setText(message);
txt.invalidate();
}
}
示例6: onBitmapLoaded
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
TextView textView = textViewWeakReference.get();
if(textView != null) {
imageDrawable = new BitmapDrawable(textView.getContext().getResources(), bitmap);
textView.invalidate();
}
}
示例7: updateAnimationFor
import android.widget.TextView; //导入方法依赖的package包/类
private void updateAnimationFor(ValueAnimator animation, TextView v) {
if (isAttachedToHierarchy(v)) {
shift = (int) animation.getAnimatedValue();
v.invalidate();
}
}
示例8: updateAnimationFor
import android.widget.TextView; //导入方法依赖的package包/类
private void updateAnimationFor(@NonNull ValueAnimator animation, @NonNull TextView v) {
if (isAttachedToHierarchy(v)) {
shift = (int) animation.getAnimatedValue();
v.invalidate();
}
}
示例9: setTextViewLineFlag
import android.widget.TextView; //导入方法依赖的package包/类
/***
* 设置TextView的划线状态
* @author 火蚁
* 2015-3-11 上午11:46:10
*
* @return void
* @param tv
* @param flag
*/
public static void setTextViewLineFlag(TextView tv, int flags) {
tv.getPaint().setFlags(flags);
tv.invalidate();
}
示例10: setBackgroundColor
import android.widget.TextView; //导入方法依赖的package包/类
/**
* {@link TextView} background color setter. Generally, the caller will
* not pass {@link Component#COLOR_DEFAULT}, instead substituting in the
* appropriate color.
*
* @param textview text view instance
* @param argb background RGB color with alpha
*/
public static void setBackgroundColor(TextView textview, int argb) {
textview.setBackgroundColor(argb);
textview.invalidate();
}
示例11: setEnabled
import android.widget.TextView; //导入方法依赖的package包/类
/**
* Enables a {@link TextView}.
*
* @param textview text view instance
* @param enabled {@code true} for enabled, {@code false} disabled
*/
public static void setEnabled(TextView textview, boolean enabled) {
textview.setEnabled(enabled);
textview.invalidate();
}
示例12: setTextColor
import android.widget.TextView; //导入方法依赖的package包/类
/**
* Sets the text color for a {@link TextView}.
*
* @param textview text view instance
* @param argb text RGB color with alpha
*/
public static void setTextColor(TextView textview, int argb) {
textview.setTextColor(argb);
textview.invalidate();
}