當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.invalidate方法代碼示例

本文整理匯總了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) {
    }
}
 
開發者ID:swustmuzi,項目名稱:PNightMode,代碼行數:26,代碼來源:ThemeUtils.java

示例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();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:31,代碼來源:TextViewUtil.java

示例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);
}
 
開發者ID:akshay2211,項目名稱:Ariana,代碼行數:10,代碼來源:Ariana.java

示例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();
    }
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:28,代碼來源:GlideDrawableTarget.java

示例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();
	}
}
 
開發者ID:dufangyu1990,項目名稱:JKApp,代碼行數:14,代碼來源:CustomDialog.java

示例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();
    }
}
 
開發者ID:Vavassor,項目名稱:Tusky,代碼行數:9,代碼來源:CustomEmojiHelper.java

示例7: updateAnimationFor

import android.widget.TextView; //導入方法依賴的package包/類
private void updateAnimationFor(ValueAnimator animation, TextView v) {
    if (isAttachedToHierarchy(v)) {
        shift = (int) animation.getAnimatedValue();
        v.invalidate();
    }
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:7,代碼來源:JumpingBeansSpan.java

示例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();
    }
}
 
開發者ID:kingwang666,項目名稱:BookLoadingView,代碼行數:7,代碼來源:JumpingBeansSpan.java

示例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();
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:14,代碼來源:ViewUtils.java

示例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();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:13,代碼來源:TextViewUtil.java

示例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();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:11,代碼來源:TextViewUtil.java

示例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();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:11,代碼來源:TextViewUtil.java


注:本文中的android.widget.TextView.invalidate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。