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


Java AbsoluteSizeSpan類代碼示例

本文整理匯總了Java中android.text.style.AbsoluteSizeSpan的典型用法代碼示例。如果您正苦於以下問題:Java AbsoluteSizeSpan類的具體用法?Java AbsoluteSizeSpan怎麽用?Java AbsoluteSizeSpan使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbsoluteSizeSpan類屬於android.text.style包,在下文中一共展示了AbsoluteSizeSpan類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSpanned

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
/**
 * Update {@link #spanned} according to the give charSequence and styles
 * @param text the give raw text.
 * @return an Spanned contains text and spans
 */
private
@NonNull
Spanned createSpanned(String text) {
  if (!TextUtils.isEmpty(text)) {
    SpannableString spannable = new SpannableString(text);
    List<SetSpanOperation> ops = createSetSpanOperation(spannable.length());
    if (mFontSize == UNSET) {
      ops.add(new SetSpanOperation(0, spannable.length(),
                                   new AbsoluteSizeSpan(WXText.sDEFAULT_SIZE)));
    }
    Collections.reverse(ops);
    for (SetSpanOperation op : ops) {
      op.execute(spannable);
    }
    return spannable;
  }
  return new SpannableString("");
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:24,代碼來源:WXTextDomObject.java

示例2: drawFollowNum

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
private void drawFollowNum(long num) {
    LogInfo.log("clf", "drawFollowNum....num=" + num);
    String followNum = StringUtils.getPlayCountsToStr(num);
    if (TextUtils.isEmpty(followNum)) {
        this.mFollowNum.setText("0");
        return;
    }
    String unit = "";
    String lastChar = followNum.substring(followNum.length() - 1);
    if (!StringUtils.isInt(lastChar)) {
        unit = " " + lastChar;
        followNum = followNum.substring(0, followNum.length() - 1) + unit;
    }
    int start = followNum.length() - unit.length();
    int end = followNum.length();
    SpannableStringBuilder sb = new SpannableStringBuilder(followNum);
    sb.setSpan(new StyleSpan(1), 0, start, 33);
    sb.setSpan(new AbsoluteSizeSpan(getResources().getDimensionPixelSize(2131165476)), start, end, 33);
    this.mFollowNum.setText(sb);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:21,代碼來源:StarActivity.java

示例3: setTextSize

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
/**
 * 設置字體大小
 * @param textSize textSize
 */
void setTextSize(int textSize) {
    Editable edit = getEditableText();
    int index = getSelectionIndex();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (star >= end)
        return;
    if (index >= 0 && index < mSections.size()) {
        TextSection section = mSections.get(index);
        section.setTextSize(textSize);
        if (mListener != null) {
            mListener.onSectionChange(section);
        }
    }
    AbsoluteSizeSpan[] styleSpans = edit.getSpans(star, end, AbsoluteSizeSpan.class);
    for (AbsoluteSizeSpan span : styleSpans) {
        edit.removeSpan(span);
    }
    edit.setSpan(new AbsoluteSizeSpan(UI.dipToPx(getContext(), textSize)), star, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    update(index);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:26,代碼來源:RichEditText.java

示例4: endCssStyle

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
private void endCssStyle(String tag, Editable text) {
    Strikethrough s = getLast(text, Strikethrough.class);
    if (s != null) {
        setSpanFromMark(tag, text, s, new StrikethroughSpan());
    }
    Background b = getLast(text, Background.class);
    if (b != null) {
        setSpanFromMark(tag, text, b, new BackgroundColorSpan(b.mBackgroundColor));
    }
    Foreground f = getLast(text, Foreground.class);
    if (f != null) {
        setSpanFromMark(tag, text, f, new ForegroundColorSpan(f.mForegroundColor));
    }
    AbsoluteSize a = getLast(text, AbsoluteSize.class);
    if (a != null) {
        setSpanFromMark(tag, text, a, new AbsoluteSizeSpan(a.getTextSize()));
    }
    RelativeSize r = getLast(text, RelativeSize.class);
    if (r != null) {
        setSpanFromMark(tag, text, r, new RelativeSizeSpan(r.getTextProportion()));
    }
}
 
開發者ID:Pixplicity,項目名稱:HtmlCompat,代碼行數:23,代碼來源:HtmlToSpannedConverter.java

示例5: itemsToColoredText

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
public Spannable[] itemsToColoredText() {
  // TODO(hal): Generalize this so that different items could have different
  // colors and even fonts and sizes
  int size = items.size();
  int displayTextSize = textSize;
  Spannable [] objects = new Spannable[size];
  for (int i = 1; i <= size; i++) {
    // Note that the ListPicker and otherPickers pickers convert Yail lists to string by calling
    // YailList.ToStringArray.
    // ListView however, does the string conversion via the adapter, so we must ensure
    // that the adapter uses YailListElementToSring
    String itemString = YailList.YailListElementToString(items.get(i));
    // Is there a more efficient way to do conversion to spannable strings that does not
    // need to allocate new objects?
    Spannable chars = new SpannableString(itemString);
    chars.setSpan(new ForegroundColorSpan(textColor),0,chars.length(),0);
    if (!container.$form().getCompatibilityMode()) {
      displayTextSize = (int) (textSize * container.$form().deviceDensity());
    }
    chars.setSpan(new AbsoluteSizeSpan(displayTextSize),0,chars.length(),0);
    objects[i - 1] = chars;
  }
  return objects;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:25,代碼來源:ListView.java

示例6: handleEndTag

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
開發者ID:Ronak-LM,項目名稱:memoir,代碼行數:26,代碼來源:ConverterSpannedToHtml.java

示例7: creSpanString

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
/**
 * 創建{文字內容、字體顏色、字體大小}分段文字集合體
 *
 * @param text
 * @param color
 * @param textSize
 * @return
 */
public static SpannableStringBuilder creSpanString(String[] text, int[] color, int[] textSize) {
    if (text == null || color == null || textSize == null)
        throw new IllegalArgumentException("參數不能為空");
    if (text.length != color.length || text.length != textSize.length)
        throw new IllegalArgumentException("參數數組長度不一致");
    SpannableStringBuilder sb = new SpannableStringBuilder();
    try {
        for (int i = 0; i < text.length; i++) {
            SpannableString sp = new SpannableString(text[i]);
            sp.setSpan(new ForegroundColorSpan(color[i]), 0, sp.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
            sp.setSpan(new AbsoluteSizeSpan(textSize[i], true), 0, sp.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            sb.append(sp);
        }
        return sb;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return sb;
}
 
開發者ID:smuyyh,項目名稱:SprintNBA,代碼行數:28,代碼來源:StringUtils.java

示例8: convert

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder holder, StockEntity.StockInfo item) {
    switch (holder.getItemViewType()) {

        case StockEntity.StockInfo.TYPE_HEADER:
            holder.setText(R.id.tv_stock_name, item.pinnedHeaderName).addOnClickListener(R.id.checkbox).setChecked(R.id.checkbox, item.check);
            break;

        case StockEntity.StockInfo.TYPE_DATA:

            final String stockNameAndCode = item.stock_name + "\n" + item.stock_code;
            SpannableStringBuilder ssb = new SpannableStringBuilder(stockNameAndCode);
            ssb.setSpan(new ForegroundColorSpan(Color.parseColor("#a4a4a7")), item.stock_name.length(), stockNameAndCode.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            ssb.setSpan(new AbsoluteSizeSpan(StockActivity.dip2px(holder.itemView.getContext(), 13)), item.stock_name.length(), stockNameAndCode.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            holder.setText(R.id.tv_stock_name_code, ssb).setText(R.id.tv_current_price, item.current_price)
                    .setText(R.id.tv_rate, (item.rate < 0 ? String.format("%.2f", item.rate) : "+" + String.format("%.2f", item.rate)) + "%");
            break;

    }
}
 
開發者ID:oubowu,項目名稱:PinnedSectionItemDecoration,代碼行數:24,代碼來源:StockAdapter.java

示例9: setTimeDay

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
private void setTimeDay(TextView textView, String day) {
    final Resources resources = textView.getResources();
    final String suffix = resources.getString(R.string.txt_day);
    final int dayLen = day.length();

    SpannableStringBuilder sBuilder = new SpannableStringBuilder();
    sBuilder.append(day) // Bold this
            .append('\n') // Default TextView font.
            .append(suffix); // Default TextView font.

    // Create the Typeface you want to apply to certain text
    CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(resources.getAssets(), "fonts/Hero.otf"));
    sBuilder.setSpan(typefaceSpan, 0, dayLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    // Font
    sBuilder.setSpan(new AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen.font_24)),
            0, dayLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    // Color
    sBuilder.setSpan(new ForegroundColorSpan(resources.getColor(R.color.cyan_700)),
            0, dayLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    textView.setText(sBuilder, TextView.BufferType.SPANNABLE);
}
 
開發者ID:qiujuer,項目名稱:UPMiss,代碼行數:23,代碼來源:RecordsViewHolder.java

示例10: updateSpannableStringBuilder

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
/**
 * Update {@link #spannableStringBuilder} according to the give charSequence and {@link #style}
 * @param text the give raw text.
 * @return an editable contains text and spans
 */
private Editable updateSpannableStringBuilder(String text) {
  spannableStringBuilder.clear();
  if (text != null) {
    spannableStringBuilder.append(text);
  }
  List<SetSpanOperation> ops = createSetSpanOperation(spannableStringBuilder.length());
  if (mFontSize == UNSET) {
    spannableStringBuilder.setSpan(
        new AbsoluteSizeSpan(WXText.sDEFAULT_SIZE), 0, spannableStringBuilder
            .length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
  }
  Collections.reverse(ops);
  for (SetSpanOperation op : ops) {
    op.execute(spannableStringBuilder);
  }
  return spannableStringBuilder;
}
 
開發者ID:Laisly,項目名稱:weex,代碼行數:23,代碼來源:WXTextDomObject.java

示例11: getCashPrice

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
/**
 * 現金券顯示價格樣式
 */
public static SpannableString getCashPrice(Context context, double oldPrice, double newPrice) {
    StringBuilder builder = new StringBuilder();
    builder.append(handleDouble(newPrice)).append("元").append(" ").append(handleDouble(oldPrice)).append("元");
    int start = 0;
    int middle = builder.indexOf(" ") + 1;
    int end = builder.length();
    SpannableString string = new SpannableString(builder);
    /*改變文字的大小*/
    string.setSpan(new AbsoluteSizeSpan(sp2px(context, 20)), start, middle, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    string.setSpan(new AbsoluteSizeSpan(sp2px(context, 14)), middle, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    /*給文字設置刪除線*/
    string.setSpan(new StrikethroughSpan(), middle, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    /*改變文字的顏色*/
    int textOrange = context.getResources().getColor(android.R.color.holo_red_light);
    int textGray = context.getResources().getColor(android.R.color.darker_gray);
    string.setSpan(new ForegroundColorSpan(textOrange), start, middle, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    string.setSpan(new ForegroundColorSpan(textGray), middle, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return string;
}
 
開發者ID:DIY-green,項目名稱:AndroidStudyDemo,代碼行數:23,代碼來源:CouponPriceUtil.java

示例12: build

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
public Spannable build() {
    SpannableStringBuilder textSpan = new SpannableStringBuilder();

    int start = 0;
    int end = 0;

    for (int i = 0; i < list.size(); i++) {
        SpanWrapper wrapper = list.get(i);
        String text = wrapper.getText();
        start = end;
        end = end + text.length();
        textSpan.append(text);

        AbsoluteSizeSpan sizeSpan = new AbsoluteSizeSpan(getContext().getResources().getDimensionPixelSize(wrapper.getTextSize()));
        ForegroundColorSpan colorSpan = new ForegroundColorSpan(getContext().getResources().getColor(wrapper.getTextColor()));

        textSpan.setSpan(sizeSpan, start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        textSpan.setSpan(colorSpan, start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    }
    return textSpan;
}
 
開發者ID:WangGanxin,項目名稱:Codebase,代碼行數:22,代碼來源:SpannableBuilder.java

示例13: about

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
private void about() {
    // 先移除所有的動態view
    linearLayout.removeView(recycle);
    linearLayout.removeView(recycle2);
    linearLayout.removeView(recycle3);
    linearLayout.removeView(about);
    linearLayout.removeView(explan);
    /* TODO 關於我們
    *
    *
    */

    String text = "\n\n\n開發成員 : \n\n陳亮宇\n張弘瑜\n鍾羽函\n蘇柏丞\n謝宣緯\n\n\n\n\t資料來源 : 行政院文化局";
    SpannableString spannable = new SpannableString(text);
    spannable.setSpan(new AbsoluteSizeSpan(80), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    spannable.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(Color.parseColor("#FF533210")), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    spannable.setSpan(new AbsoluteSizeSpan(100), 3, 7, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    spannable.setSpan(new AbsoluteSizeSpan(100), 36, 40, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    about.setText(spannable);
    linearLayout.addView(about);

}
 
開發者ID:RedFishCHANG,項目名稱:ReadWorld,代碼行數:26,代碼來源:MainActivity.java

示例14: info

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
private void info() {
    // 先移除所有的動態view
    linearLayout.removeView(recycle);
    linearLayout.removeView(recycle2);
    linearLayout.removeView(recycle3);
    linearLayout.removeView(about);
    linearLayout.removeView(explan);
    /* TODO 說明
    *
    *
    */
    String text = "\n\n\n    這是一個彙整台灣獨立書店的app,資料取自文化局的開放資源,主要目的在於提供沒接觸過或是剛接觸獨立書店的民眾,可以找尋到自己生活周遭哪裡有獨立書店,該如何拜訪、參觀,並且了解各個獨立店家的特色";
    SpannableString spannable = new SpannableString(text);
    spannable.setSpan(new AbsoluteSizeSpan(80), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    spannable.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_NORMAL), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(Color.parseColor("#FF533210")), 0, text.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

    explan.setText(spannable);
    linearLayout.addView(explan);

}
 
開發者ID:RedFishCHANG,項目名稱:ReadWorld,代碼行數:22,代碼來源:MainActivity.java

示例15: onBindViewHolder

import android.text.style.AbsoluteSizeSpan; //導入依賴的package包/類
@Override
public void onBindViewHolder(MovieHolder holder, final int position) {
    String movieName = list.get(position).getMovieName();
    String briefIntro = list.get(position).getBriefIntro();

    String content = movieName + "\n\n" + briefIntro;
    SpannableStringBuilder style = new SpannableStringBuilder(content);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(20)), 0, movieName.length(),
            SPAN_INCLUSIVE_INCLUSIVE);
    style.setSpan(new AbsoluteSizeSpan(SystemUtil.dp2px(14)), movieName.length() + 2, content.length
            () - 1, SPAN_INCLUSIVE_INCLUSIVE);
    holder.mTvContent.setText(style);

    GlideUtil.setImage(mContext, list.get(position).getPic(), holder.mIvMovie);
    holder.mCvMovie.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.click(list.get(position));
            }
        }
    });
}
 
開發者ID:4FunApp,項目名稱:4Fun,代碼行數:24,代碼來源:MovieAdapter.java


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