当前位置: 首页>>代码示例>>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;未经允许,请勿转载。