本文整理匯總了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();
}