android.text.style.AbsoluteSizeSpan Java Examples
The following examples show how to use
android.text.style.AbsoluteSizeSpan.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: tysq-android Author: tysqapp File: MineFragment.java License: GNU General Public License v3.0 | 6 votes |
/** * 设置信息 * * @param textView * @param sourceId * @param info */ private void setSpanInfo(TextView textView, int sourceId, String info) { String content = String.format(getString(sourceId), info); AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(18, true); SpannableString spannableString = new SpannableString(content); spannableString.setSpan(absoluteSizeSpan, content.length() - info.length(), content.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannableString); }
Example #2
Source Project: tysq-android Author: tysqapp File: MineFragment.java License: GNU General Public License v3.0 | 6 votes |
/** * 设置 "文章"、"评论"、"收藏" */ private void setArticleInfoSpanInfo(TextView textView, int sourceId, String info) { String content = String.format(getString(sourceId), info); AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(20, true); SpannableString spannableString = new SpannableString(content); spannableString.setSpan(absoluteSizeSpan, 0, info == null ? 0 : info.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannableString); }
Example #3
Source Project: FastWaiMai Author: zion223 File: DiscountAdapter.java License: MIT License | 6 votes |
@Override protected void convert(BaseViewHolder helper, MultipleItemEntity item) { switch (helper.getItemViewType()){ case DiscountCardItemType.ITEM_NORMAL_AVAILIABLE: String shopName = item.getField(DiscountItemFields.SHOP_NAME); helper.setText(R.id.tv_item_discount_shopname, shopName); String type = item.getField(DiscountItemFields.TYPE); helper.setText(R.id.tv_item_discount_type, type); String expireTime = item.getField(DiscountItemFields.EXPIRE_TIME); helper.setText(R.id.tv_item_discount_expiretime, "有效期至" + expireTime); String orimoney = item.getField(DiscountItemFields.MONEY); final SpannableString money = new SpannableString(orimoney); money.setSpan(new AbsoluteSizeSpan(13, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); helper.setText(R.id.tv_item_discount_money, money); String condition = item.getField(DiscountItemFields.CONDITION); helper.setText(R.id.tv_item_discount_condition, condition); break; case DiscountCardItemType.ITEM_NORMAL_UNAVAILIABLE: break; default: break; } }
Example #4
Source Project: graphhopper-navigation-android Author: graphhopper File: EmbeddedNavigationActivity.java License: MIT License | 6 votes |
private void setSpeed(Location location) { String string = String.format("%d\nMPH", (int) (location.getSpeed() * 2.2369)); int mphTextSize = getResources().getDimensionPixelSize(R.dimen.mph_text_size); int speedTextSize = getResources().getDimensionPixelSize(R.dimen.speed_text_size); SpannableString spannableString = new SpannableString(string); spannableString.setSpan(new AbsoluteSizeSpan(mphTextSize), string.length() - 4, string.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); spannableString.setSpan(new AbsoluteSizeSpan(speedTextSize), 0, string.length() - 3, Spanned.SPAN_INCLUSIVE_INCLUSIVE); speedWidget.setText(spannableString); if (!instructionListShown) { speedWidget.setVisibility(View.VISIBLE); } }
Example #5
Source Project: customview-samples Author: hyhdy File: CustomSpanData.java License: Apache License 2.0 | 6 votes |
@Override public CharacterStyle onCreateSpan() { switch (mSpanType){ case TYPE_ABS_SIZE_SPAN: switch (mUnit){ case UNIT_PX: return new AbsoluteSizeSpan((int) mTextSize); case UNIT_SP: return new AbsoluteSizeSpan((int) mTextSize,true); } case TYPE_CUSTOM_TEXT_SPAN: return new CustomTextSpan(mUnit,mTextSize, mTypeface, mColor, mLeftMarginDp, mAlign); default: return new CustomTextSpan(mUnit,mTextSize, mTypeface, mColor, mLeftMarginDp, mAlign); } }
Example #6
Source Project: letv Author: JackChan1999 File: StarActivity.java License: Apache License 2.0 | 6 votes |
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); }
Example #7
Source Project: PinnedSectionItemDecoration Author: oubowu File: StockAdapter.java License: Apache License 2.0 | 6 votes |
@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; } }
Example #8
Source Project: HtmlCompat Author: Pixplicity File: HtmlToSpannedConverter.java License: Apache License 2.0 | 6 votes |
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())); } }
Example #9
Source Project: appinventor-extensions Author: mit-cml File: ListView.java License: Apache License 2.0 | 6 votes |
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; }
Example #10
Source Project: memoir Author: ronak-manglani File: ConverterSpannedToHtml.java License: Apache License 2.0 | 6 votes |
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>"); } }
Example #11
Source Project: AndroidStudyDemo Author: DIY-green File: CouponPriceUtil.java License: GNU General Public License v2.0 | 6 votes |
/** * 现金券显示价格样式 */ 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; }
Example #12
Source Project: XMiTools Author: tianma8023 File: BatteryMeterViewHook.java License: GNU General Public License v3.0 | 5 votes |
private void hookUpdateShowPercent() { XposedWrapper.findAndHookMethod(CLASS_BATTERY_VIEW, mClassLoader, "updateShowPercent", new MethodHookWrapper() { @Override protected void after(MethodHookParam param) { TextView mBatteryPercentView = (TextView) XposedHelpers .getObjectField(param.thisObject, "mBatteryPercentView"); if (mBatteryPercentView != null) { CharSequence cs = mBatteryPercentView.getText(); if (cs == null) { return; } String text = cs.toString(); int percentSignIdx = text.indexOf('%'); if (percentSignIdx != -1) { SpannableString ss = new SpannableString(text); float originSize = mBatteryPercentView.getTextSize(); ss.setSpan(new AbsoluteSizeSpan((int) (originSize * 3 / 4)), percentSignIdx, percentSignIdx + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mBatteryPercentView.setText(ss); } } } }); }
Example #13
Source Project: weex Author: Laisly File: WXTextDomObject.java License: Apache License 2.0 | 5 votes |
/** * Create a task list which contains {@link SetSpanOperation}. The task list will be executed * in other method. * @param end the end character of the text. * @return a task list which contains {@link SetSpanOperation}. */ private List<SetSpanOperation> createSetSpanOperation(int end) { List<SetSpanOperation> ops = new LinkedList<>(); int start = 0; if (end >= start) { if (mTextDecoration == WXTextDecoration.UNDERLINE) { ops.add(new SetSpanOperation(start, end, new UnderlineSpan())); } if (mTextDecoration == WXTextDecoration.LINETHROUGH) { ops.add(new SetSpanOperation(start, end, new StrikethroughSpan())); } if (mIsColorSet) { ops.add(new SetSpanOperation(start, end, new ForegroundColorSpan(mColor))); } if (mFontSize != UNSET) { ops.add(new SetSpanOperation(start, end, new AbsoluteSizeSpan(mFontSize))); } if (mFontStyle != UNSET || mFontWeight != UNSET || mFontFamily != null) { ops.add(new SetSpanOperation(start, end, new WXCustomStyleSpan(mFontStyle, mFontWeight, mFontFamily))); } ops.add(new SetSpanOperation(start, end, new AlignmentSpan.Standard(mAlignment))); if(mLineHeight !=UNSET) { ops.add(new SetSpanOperation(start, end, new WXLineHeightSpan(mLineHeight))); } } return ops; }
Example #14
Source Project: tysq-android Author: tysqapp File: PersonalHomePageFragment.java License: GNU General Public License v3.0 | 5 votes |
/** * 设置个人成就富文本 */ private void setAchievementInfo(TextView textView, String quantity, int stringRes) { String content = getString(stringRes); String resultContent = String.format(content, quantity); int length = quantity.length(); SpannableStringBuilder builder = new SpannableStringBuilder(resultContent); builder.setSpan(new JerryBoldSpan(), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.main_text_color)), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new AbsoluteSizeSpan(16, true), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(builder); }
Example #15
Source Project: FastWaiMai Author: zion223 File: SubmitDelegate.java License: MIT License | 5 votes |
@Override public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View view) { //支付方式 initPayCheckBox(); //订单支付剩余时间15min开始倒计时 initPayLeftTime(); //支付金额 final SpannableString paymoney = new SpannableString("¥24.8"); paymoney.setSpan(new AbsoluteSizeSpan(20, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mTvPayMoney.setText(paymoney); }
Example #16
Source Project: FastWaiMai Author: zion223 File: PersonalDelegate.java License: MIT License | 5 votes |
private void initView() { final SpannableString redEnvelope = new SpannableString("0个未使用"); redEnvelope.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); redEnvelope.setSpan(new AbsoluteSizeSpan(17, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); redEnvelope.setSpan(new AbsoluteSizeSpan(13, true), 1, redEnvelope.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); final SpannableString discount = new SpannableString("12张未使用"); discount.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); discount.setSpan(new AbsoluteSizeSpan(17, true), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); discount.setSpan(new AbsoluteSizeSpan(13, true), 2, discount.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); final SpannableString bounty = new SpannableString("20元可叠加满减"); bounty.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); bounty.setSpan(new AbsoluteSizeSpan(17, true), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); bounty.setSpan(new AbsoluteSizeSpan(13, true), 2, bounty.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mTvRedEnvelope.setText(redEnvelope); mTvDiscount.setText(discount); mTvBounty.setText(bounty); final SpannableString payment = new SpannableString("28元"); payment.setSpan(new AbsoluteSizeSpan(17, true), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); bounty.setSpan(new AbsoluteSizeSpan(9, true), 2, payment.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); final SpannableString benefit = new SpannableString("165元"); benefit.setSpan(new AbsoluteSizeSpan(17, true), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); bounty.setSpan(new AbsoluteSizeSpan(9, true), 3, benefit.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mTvPayment.setText(payment); mTvBenefit.setText(benefit); }
Example #17
Source Project: youqu_master Author: wangfeng19930909 File: UiUtils.java License: Apache License 2.0 | 5 votes |
/** * 设置hint大小 * * @param size * @param v * @param res */ public static void setViewHintSize(Context context, int size, TextView v, int res) { SpannableString ss = new SpannableString(getResources(context).getString( res)); // 新建一个属性对象,设置文字的大小 AbsoluteSizeSpan ass = new AbsoluteSizeSpan(size, true); // 附加属性到文本 ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 设置hint v.setHint(new SpannedString(ss)); // 一定要进行转换,否则属性会消失 }
Example #18
Source Project: TikTok Author: TaoPaox File: MvpUtils.java License: Apache License 2.0 | 5 votes |
/** * 设置hint大小 * * @param size * @param v * @param res */ public static void setViewHintSize(Context context, int size, TextView v, int res) { SpannableString ss = new SpannableString(getResources(context).getString( res)); // 新建一个属性对象,设置文字的大小 AbsoluteSizeSpan ass = new AbsoluteSizeSpan(size, true); // 附加属性到文本 ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 设置hint v.setHint(new SpannedString(ss)); // 一定要进行转换,否则属性会消失 }
Example #19
Source Project: nono-android Author: tianyuan168326 File: BaseRichEditText.java License: GNU General Public License v3.0 | 5 votes |
public void applyAbsoluteSpan(int px){ int selStart=getSelectionStart(); int selEnd=getSelectionEnd(); if(selEnd-selStart>0){ AbsoluteSizeSpan[] ss = getEditableText().getSpans(selStart, selEnd, AbsoluteSizeSpan.class); for (AbsoluteSizeSpan span:ss) { removeSpan(span, selStart, selEnd); } setSpan(new AbsoluteSizeSpan(px),selStart,selEnd,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }
Example #20
Source Project: timecat Author: triline3 File: MeechaoDataUtils.java License: Apache License 2.0 | 5 votes |
/** * 标签格式化 * * @param labelTopicValue 标签 内容 * * @return s */ public static SpannableStringBuilder covTopicVal(String labelTopicValue) { SpannableStringBuilder spannableString = new SpannableStringBuilder(labelTopicValue); if (TextUtils.isEmpty(labelTopicValue)) { return spannableString; } spannableString.setSpan(new AbsoluteSizeSpan(0, true), labelTopicValue.indexOf("["), labelTopicValue.indexOf("]") + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spannableString; }
Example #21
Source Project: UPMiss Author: qiujuer File: QuickFragment.java License: GNU General Public License v3.0 | 5 votes |
private CharSequence getTopText(long occupancy, final String suffix) { final String str = String.valueOf(occupancy) + "\n" + suffix; final int len = str.length(); final int lenFx = len - suffix.length(); final Resources resources = getResources(); SpannableString span = new SpannableString(str); span.setSpan(new AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen.font_20)), 0, lenFx, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new ForegroundColorSpan(resources.getColor(R.color.white_alpha_224)), 0, lenFx, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return span; }
Example #22
Source Project: SimpleProject Author: Liberuman File: SpannableStringUtil.java License: MIT License | 5 votes |
/** * 设置多个位置的文字大小 * @param text * @param textSize * @param startPos * @param len * @return */ public static SpannableString getTextSizeSpannable(String text, int textSize, int[] startPos, int[] len) { SpannableString span = new SpannableString(text); if (startPos != null && len != null && startPos.length > 0 && len.length > 0 && startPos.length == len.length) { for (int i = 0; i < startPos.length; i++) { span.setSpan(new AbsoluteSizeSpan(textSize), startPos[i], startPos[i]+len[i], Spanned.SPAN_INCLUSIVE_INCLUSIVE); } } return span; }
Example #23
Source Project: react-native-GPay Author: hellochirag File: ReactEditText.java License: MIT License | 5 votes |
/** * Remove and/or add {@link Spanned.SPAN_EXCLUSIVE_EXCLUSIVE} spans, since they should only exist * as long as the text they cover is the same. All other spans will remain the same, since they * will adapt to the new text, hence why {@link SpannableStringBuilder#replace} never removes * them. */ private void manageSpans(SpannableStringBuilder spannableStringBuilder) { Object[] spans = getText().getSpans(0, length(), Object.class); for (int spanIdx = 0; spanIdx < spans.length; spanIdx++) { // Remove all styling spans we might have previously set if (ForegroundColorSpan.class.isInstance(spans[spanIdx]) || BackgroundColorSpan.class.isInstance(spans[spanIdx]) || AbsoluteSizeSpan.class.isInstance(spans[spanIdx]) || CustomStyleSpan.class.isInstance(spans[spanIdx]) || ReactTagSpan.class.isInstance(spans[spanIdx])) { getText().removeSpan(spans[spanIdx]); } if ((getText().getSpanFlags(spans[spanIdx]) & Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) != Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) { continue; } Object span = spans[spanIdx]; final int spanStart = getText().getSpanStart(spans[spanIdx]); final int spanEnd = getText().getSpanEnd(spans[spanIdx]); final int spanFlags = getText().getSpanFlags(spans[spanIdx]); // Make sure the span is removed from existing text, otherwise the spans we set will be // ignored or it will cover text that has changed. getText().removeSpan(spans[spanIdx]); if (sameTextForSpan(getText(), spannableStringBuilder, spanStart, spanEnd)) { spannableStringBuilder.setSpan(span, spanStart, spanEnd, spanFlags); } } }
Example #24
Source Project: react-native-GPay Author: hellochirag File: ReactTextTest.java License: MIT License | 5 votes |
@Test public void testFontSizeApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.FONT_SIZE, 21.0), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); AbsoluteSizeSpan sizeSpan = getSingleSpan( (TextView) rootView.getChildAt(0), AbsoluteSizeSpan.class); assertThat(sizeSpan.getSize()).isEqualTo(21); }
Example #25
Source Project: PLDroidShortVideo Author: pili-engineering File: VideoMixRecordActivity.java License: Apache License 2.0 | 5 votes |
private void showDescription(String filterName, int time) { SpannableString description = new SpannableString(String.format("%s%n<<左右滑动切换滤镜>>", filterName)); description.setSpan(new AbsoluteSizeSpan(30, true), 0, filterName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); description.setSpan(new AbsoluteSizeSpan(14, true), filterName.length(), description.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); mFilterDescription.removeCallbacks(effectDescriptionHide); mFilterDescription.setVisibility(View.VISIBLE); mFilterDescription.setText(description); mFilterDescription.postDelayed(effectDescriptionHide, time); }
Example #26
Source Project: CrazyDaily Author: crazysunj File: PhotoPickerBucketAdapter.java License: Apache License 2.0 | 5 votes |
private CharSequence getInfo(String bucketId, String bucketName, int count) { SpannableStringBuilder builder = new SpannableStringBuilder(bucketName); builder.setSpan(new ForegroundColorSpan(Color.parseColor("#333333")), 0, bucketName.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE); builder.setSpan(new AbsoluteSizeSpan(16, true), 0, bucketName.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); if (!String.valueOf(Integer.MAX_VALUE).equals(bucketId)) { builder.append("\n").append(String.valueOf(count)).append("张"); builder.setSpan(new ForegroundColorSpan(Color.parseColor("#999999")), bucketName.length(), builder.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE); builder.setSpan(new AbsoluteSizeSpan(12, true), bucketName.length(), builder.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } return builder; }
Example #27
Source Project: StickyItemDecoration Author: oubowu File: StockAdapter.java License: Apache License 2.0 | 5 votes |
private void setData(RecyclerViewHolder holder, StockEntity.StockInfo item) { 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(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)) + "%"); }
Example #28
Source Project: RichEditor Author: DrownCoder File: RichShowAdapter.java License: Apache License 2.0 | 5 votes |
private void bindTextComponent(RecyclerView.ViewHolder holder, int i, RichModel item) { if (holder instanceof TextViewHolder) { TextViewHolder textHolder = (TextViewHolder) holder; TextView tv = textHolder.mTv; if (item.isParagraphStyle) { SpannableStringBuilder spannableString = new SpannableStringBuilder(item.source); for (Object obj : item.paragraphSpan.mSpans) { if (obj instanceof AbsoluteSizeSpan) { AbsoluteSizeSpan sizeSpan = (AbsoluteSizeSpan) obj; tv.setTextSize(sizeSpan.getSize()); continue; } spannableString.setSpan(obj, 0, item.source.length(), Spanned .SPAN_EXCLUSIVE_EXCLUSIVE); } tv.setText(spannableString); paragraphHelper.handleTextStyle(tv, item.paragraphSpan.paragraphType); } else { mSpanString.clear(); mSpanString.clearSpans(); mSpanString.append(item.source); if (item.getSpanList() != null) { for (SpanModel span : item.getSpanList()) { mSpanString.setMultiSpans(span.mSpans, span.start, span.end, Spanned .SPAN_EXCLUSIVE_EXCLUSIVE); } } tv.setText(mSpanString); paragraphHelper.handleTextStyle(tv, -1); } } }
Example #29
Source Project: RichEditor Author: DrownCoder File: MarkDownParser.java License: Apache License 2.0 | 5 votes |
private String paragraphToMarkDown(List<Object> mSpans, StringBuilder source) { if (mSpans == null || mSpans.size() == 0) { return source.toString(); } String str = source.toString(); for (Object obj : mSpans) { if (obj instanceof ReferSpan) { str = formater.formatRefer(str); } else if (obj instanceof AlignmentSpan) { //markdown是不支持居中的!!!,后期考虑注释掉 // str = formater.formatCenter(str); } else if (obj instanceof AbsoluteSizeSpan) { AbsoluteSizeSpan sizeSpan = (AbsoluteSizeSpan) obj; switch (sizeSpan.getSize()) { case Const.T1_SIZE: str = formater.formatH1(str); break; case Const.T2_SIZE: str = formater.formatH2(str); break; case Const.T3_SIZE: str = formater.formatH3(str); break; case Const.T4_SIZE: str = formater.formatH4(str); break; } } } return str; }
Example #30
Source Project: RichEditor Author: DrownCoder File: CharacterFactory.java License: Apache License 2.0 | 5 votes |
/** * 创建字号span */ private void createSizeSpan(String code, List<CharacterStyle> characterStyles) { try { if (TextUtils.isEmpty(code) || Integer.parseInt(code) <= 0) return; AbsoluteSizeSpan sizeSpan = new AbsoluteSizeSpan(Integer.parseInt(code)); characterStyles.add(sizeSpan); } catch (NumberFormatException e) { Log.e(Const.BASE_LOG, "font size value is not true!"); } }