android.widget.TextView.isInEditMode()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中android.widget.TextView.isInEditMode()方法的一些代码示例,展示了TextView.isInEditMode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.isInEditMode()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:isInEditMode

TextView.isInEditMode介绍

暂无

代码示例

代码示例来源:origin: workarounds/typography

public static void setTypography(android.widget.TextView textView, AttributeSet attrs){
  if(!textView.isInEditMode()) {
    setTypeface(textView, attrs);
  }
}

代码示例来源:origin: GrossumUA/TAS_Android_Boilerplate

public static void setupTypefaceToTextView(TextView tv, AttributeSet attrs) {
  if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    applyFixForPre21ver(tv);
  }
  if (!tv.isInEditMode() && attrs != null) {
    TypedArray typedArray = tv.getContext().obtainStyledAttributes(
      attrs,
      R.styleable.CustomFontTextView);
    final int fontIndex = typedArray.getInt(R.styleable.CustomFontTextView_customFontName, -1);
    if (fontIndex < 0) {
      typedArray.recycle();
      throw new IllegalArgumentException("You must provide attribute \"customFontName\" for your CustomFontTextView");
    } else {
      final Typeface customTypeface = CustomFont.findByIndex(fontIndex).orElse(CustomFont.CLANT_OT_NARR_BOOK)
        .asTypeface(tv.getContext());
      tv.setTypeface(customTypeface);
      typedArray.recycle();
    }
  }
}

代码示例来源:origin: neopixl/PixlUI

public static void onDrawHelper(Canvas canvas, TextView target, DrawCallback drawCallback) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
    if (target.isInEditMode())
      return;
  }
  final ExtraFontData data = getFontData(target, false);
  if (data == null)
    return;
  if (data.borderWidth > 0) {
    final Paint paint = target.getPaint();
    // setup stroke
    final Style oldStyle = paint.getStyle();
    final ColorStateList oldTextColors = target.getTextColors();
    final float oldStrokeWidth = paint.getStrokeWidth();
    target.setTextColor(data.borderColor);
    paint.setStyle(Style.STROKE);
    paint.setStrokeWidth(data.borderWidth);
    callDrawCallback(drawCallback, canvas);
    target.setTextColor(oldTextColors);
    paint.setStyle(oldStyle);
    paint.setStrokeWidth(oldStrokeWidth);
  }
}

相关文章

微信公众号

最新文章

更多

TextView类方法