Java 类android.text.style.RelativeSizeSpan 实例源码

项目:GoSCELE    文件:ScheduleDailyProvider.java   
@Override
public RemoteViews getViewAt(int position) {
    ScheduleDailyGroupModel model = list.get(position);
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.layout_schedule_daily_widget);

    remoteViews.setTextViewText(R.id.title_schedule_daily, model.day);

    CharSequence builder = null;
    for (ScheduleDailyModel e : model.scheduleDailyModels()) {
        String course = e.desc.substring(0, e.desc.indexOf(" Ruang: "));
        String room = e.desc.substring(e.desc.indexOf(" Ruang: ") + 8);
        SpannableString title = new SpannableString(course);
        title.setSpan(new RelativeSizeSpan(1.2f), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        SpannableString time = new SpannableString("R. " + room + "\t\t" + e.time);
        time.setSpan(new ForegroundColorSpan(context.getResources().getColor(android.R.color.darker_gray)), 0, time.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (builder == null) {
            builder = TextUtils.concat(title, "\n", time + "\n\n");
        } else {
            builder = TextUtils.concat(builder, title, "\n", time + "\n\n");
        }
    }
    remoteViews.setTextViewText(R.id.content_schedule_daily, builder == null ? "(empty)\n\n" : builder);

    return remoteViews;
}
项目:PeSanKita-android    文件:PassphrasePromptActivity.java   
private void initializeResources() {
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.centered_app_title);

  ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);

  showButton       = (ImageButton)     findViewById(R.id.passphrase_visibility);
  hideButton       = (ImageButton)     findViewById(R.id.passphrase_visibility_off);
  visibilityToggle = (AnimatingToggle) findViewById(R.id.button_toggle);
  passphraseText   = (EditText)        findViewById(R.id.passphrase_edit);
  SpannableString hint = new SpannableString("  " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
  hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

  passphraseText.setHint(hint);
  okButton.setOnClickListener(new OkButtonClickListener());
  showButton.setOnClickListener(new ShowButtonOnClickListener());
  hideButton.setOnClickListener(new HideButtonOnClickListener());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
项目:PeSanKita-android    文件:ComposeText.java   
public void setHint(@NonNull String hint, @Nullable CharSequence subHint) {
  this.hint = new SpannableString(hint);
  this.hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);

  if (subHint != null) {
    this.subHint = new SpannableString(subHint);
    this.subHint.setSpan(new RelativeSizeSpan(0.8f), 0, subHint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
  } else {
    this.subHint = null;
  }

  if (this.subHint != null) {
    super.setHint(new SpannableStringBuilder().append(ellipsizeToWidth(this.hint))
                                              .append("\n")
                                              .append(ellipsizeToWidth(this.subHint)));
  } else {
    super.setHint(ellipsizeToWidth(this.hint));
  }
}
项目:Watermark    文件:BucketAdapter.java   
@Override
public void onBindViewHolder(BucketViewHolder holder, int position) {
    BucketBean bucketBean = mBucketList.get(position);
    String bucketName = bucketBean.getBucketName();
    if (position != 0) {
        SpannableString nameSpannable = new SpannableString(bucketName + "\n" + bucketBean.getImageCount() + "张");
        nameSpannable.setSpan(new ForegroundColorSpan(Color.GRAY), bucketName.length(), nameSpannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        nameSpannable.setSpan(new RelativeSizeSpan(0.8f), bucketName.length(), nameSpannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        holder.mTvBucketName.setText(nameSpannable);
    } else {
        holder.mTvBucketName.setText(bucketName);
    }
    if (mSelectedBucket != null && TextUtils.equals(mSelectedBucket.getBucketId(), bucketBean.getBucketId())) {
        holder.mRbSelected.setVisibility(View.VISIBLE);
        holder.mRbSelected.setChecked(true);
    } else {
        holder.mRbSelected.setVisibility(View.GONE);
    }

    String path = bucketBean.getCover();
    mConfiguration.getImageLoader()
            .displayImage(holder.itemView.getContext(), path, holder.mIvBucketCover, mDefaultImage, mConfiguration.getImageConfig(),
                    true, mConfiguration.isPlayGif(), 100, 100, bucketBean.getOrientation());
}
项目:DailyStudy    文件:SpannableStringActivity.java   
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    switch (msg.what) {
        case 0x001:
            SpannableString string = new SpannableString("设置文字的前景色为淡蓝色");
            RelativeSizeSpan sizeSpan = new RelativeSizeSpan(1.5f);
            string.setSpan(sizeSpan, pos, pos + 1, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
            bgtext.setText(string);
            pos++;
            if (pos >= bgtext.getText().length()) {
                pos = 0;
            }
            Message ms = Message.obtain();
            ms.what = 0x001;
            handler.sendEmptyMessageDelayed(0x001, 150);
            break;
    }
}
项目:ShangHanLun    文件:ShowFragment.java   
public SpannableStringBuilder spannerbleTitleForHeaderInSection(
        ATableView tableView, int section) {
    HH2SectionData sd = data.get(section);
    String text = sd.getHeader();
    SpannableStringBuilder builder = new SpannableStringBuilder(text);
    builder.setSpan(new ForegroundColorSpan(Color.BLUE), 0,
            text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (text.contains("$")) {
        int index = text.indexOf("$") + 1;
        builder.setSpan(new ForegroundColorSpan(Color.RED), index,
                text.length(),
                SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.setSpan(new RelativeSizeSpan(0.55f), index,
                text.length(),
                SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.replace(index - 1, index, "\n");
    }

    return builder;
}
项目:HtmlCompat    文件:HtmlToSpannedConverter.java   
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()));
    }
}
项目:Cable-Android    文件:PassphrasePromptActivity.java   
private void initializeResources() {
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.centered_app_title);

  ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);

  showButton       = (ImageButton)     findViewById(R.id.passphrase_visibility);
  hideButton       = (ImageButton)     findViewById(R.id.passphrase_visibility_off);
  visibilityToggle = (AnimatingToggle) findViewById(R.id.button_toggle);
  passphraseText   = (EditText)        findViewById(R.id.passphrase_edit);
  SpannableString hint = new SpannableString("  " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
  hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

  passphraseText.setHint(hint);
  okButton.setOnClickListener(new OkButtonClickListener());
  showButton.setOnClickListener(new ShowButtonOnClickListener());
  hideButton.setOnClickListener(new HideButtonOnClickListener());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
项目:Cable-Android    文件:ComposeText.java   
public void setHint(@NonNull String hint, @Nullable CharSequence subHint) {
  this.hint = hint;

  if (subHint != null) {
    this.subHint = new SpannableString(subHint);
    this.subHint.setSpan(new RelativeSizeSpan(0.5f), 0, subHint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
  } else {
    this.subHint = null;
  }

  if (this.subHint != null) {
    super.setHint(new SpannableStringBuilder().append(ellipsizeToWidth(this.hint))
                                              .append("\n")
                                              .append(ellipsizeToWidth(this.subHint)));
  } else {
    super.setHint(ellipsizeToWidth(this.hint));
  }
}
项目:DeviceInfo    文件:Methods.java   
/**
     * Set string with spannable.
     */
    public static SpannableStringBuilder getSpannablePriceTotalText(Context context, String text, String fontPath, boolean setFontBigger) {

        String[] result = text.split("=");
        String first = result[0];
        String second = result[1];
        first = first.concat("=");

        Typeface font = Typeface.createFromAsset(context.getAssets(), fontPath);

        SpannableStringBuilder builder = new SpannableStringBuilder();

        SpannableString dkgraySpannable = new SpannableString(first + "");
        builder.append(dkgraySpannable);

        SpannableString blackSpannable = new SpannableString(second);
        if (setFontBigger) {
            blackSpannable.setSpan(new RelativeSizeSpan(1.3f), 0, second.length(), 0); // set size
        }
//        blackSpannable.setSpan(new CustomTypefaceSpan("", font), 0, second.length(), 0); // font weight
        builder.append(blackSpannable);

        return builder;
    }
项目:android_packages_apps_tv    文件:CaptionWindowLayout.java   
public void setPenAttr(CaptionPenAttr penAttr) {
    mCharacterStyles.clear();
    if (penAttr.italic) {
        mCharacterStyles.add(new StyleSpan(Typeface.ITALIC));
    }
    if (penAttr.underline) {
        mCharacterStyles.add(new UnderlineSpan());
    }
    switch (penAttr.penSize) {
        case CaptionPenAttr.PEN_SIZE_SMALL:
            mCharacterStyles.add(new RelativeSizeSpan(PROPORTION_PEN_SIZE_SMALL));
            break;
        case CaptionPenAttr.PEN_SIZE_LARGE:
            mCharacterStyles.add(new RelativeSizeSpan(PROPORTION_PEN_SIZE_LARGE));
            break;
    }
    switch (penAttr.penOffset) {
        case CaptionPenAttr.OFFSET_SUBSCRIPT:
            mCharacterStyles.add(new SubscriptSpan());
            break;
        case CaptionPenAttr.OFFSET_SUPERSCRIPT:
            mCharacterStyles.add(new SuperscriptSpan());
            break;
    }
}
项目:memoir    文件:ConverterHtmlToSpanned.java   
private void endHeader() {
    int len = mResult.length();
    Object obj = getLast(Header.class);

    int where = mResult.getSpanStart(obj);

    mResult.removeSpan(obj);

    // Back off not to change only the text, not the blank line.
    while (len > where && mResult.charAt(len - 1) == '\n') {
        len--;
    }

    if (where != len) {
        Header h = (Header) obj;
        mResult.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]), where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mResult.setSpan(new BoldSpan(), where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
项目:memoir    文件:ConverterHtmlToSpanned.java   
private void endHeader() {
    int len = mResult.length();
    Object obj = getLast(Header.class);

    int where = mResult.getSpanStart(obj);

    mResult.removeSpan(obj);

    // Back off not to change only the text, not the blank line.
    while (len > where && mResult.charAt(len - 1) == '\n') {
        len--;
    }

    if (where != len) {
        Header h = (Header) obj;
        mResult.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]), where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mResult.setSpan(new BoldSpan(), where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
项目:TextSecure    文件:PassphrasePromptActivity.java   
private void initializeResources() {
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.light_centered_app_title);
  mitigateAndroidTilingBug();

  ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);
  passphraseText       = (EditText)    findViewById(R.id.passphrase_edit);
  SpannableString hint = new SpannableString(getString(R.string.PassphrasePromptActivity_enter_passphrase));

  hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new ForegroundColorSpan(0x66000000), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  passphraseText.setHint(hint);
  okButton.setOnClickListener(new OkButtonClickListener());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
项目:iqra-android    文件:SearchResultsActivity.java   
private void onTranslationChanged() throws JSONException {
    SpannableString ss1 = new SpannableString(getResources().getString(R.string.getting_match));
    ss1.setSpan(new RelativeSizeSpan(1.7f), 0, ss1.length(), 0);

    final ProgressDialog progress = new ProgressDialog(this);
    progress.setMessage(ss1);
    progress.setCancelable(false);
    progress.show();

    RequestDelegate requestDelegate = RequestDelegate.getInstance(getApplicationContext());
    requestDelegate.performTranslationChange(prefs.getString("translation", "en-hilali"), getAllCurrentAyahs(), new NetworkRequestCallback() {
        @Override
        public void onSuccess(JSONObject response) {
            Log.v(TAG, response.toString());
            parseTranslationResponse(response);
            progress.dismiss();
        }

        @Override
        public void onFailure(Throwable error) {
            onSearchQueryError(error);
            progress.dismiss();
        }
    });
}
项目:nono-android    文件:MyHtmlTagHandler.java   
private void processSup( boolean opening, Editable output) {
    int len = output.length();
    if(opening) {
        //output.setSpan(new AbsoluteSizeSpan(scriptSize,false), len, len, Spannable.SPAN_MARK_MARK);
        //output.setSpan(new RelativeSizeSpan(0.5f), len, len, Spannable.SPAN_MARK_MARK);
        output.setSpan(new SuperscriptSpan(), len, len, Spannable.SPAN_MARK_MARK);
    } else {
        Object obj = getLast(output, SuperscriptSpan.class);
        int where = output.getSpanStart(obj);
        output.removeSpan(obj);
        //obj = getLast(output, RelativeSizeSpan.class);
        //output.removeSpan(obj);
        if (where != len&&where>=0) {
            //output.setSpan(new AbsoluteSizeSpan(scriptSize, false), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            output.setSpan(new RelativeSizeSpan(0.7f), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            output.setSpan(new SuperscriptSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        //obj = getLast(output, AbsoluteSizeSpan.class);
        //where = output.getSpanStart(obj);
        //output.removeSpan(obj);
        //if (where != len) {
        //    output.setSpan(new AbsoluteSizeSpan(scriptSize, false), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        //    //output.setSpan(new RelativeSizeSpan(0.5f), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        //}
    }
}
项目:chaincloud-v    文件:BitcoinUtil.java   
public static void formatSignificant(final Editable s, final RelativeSizeSpan
        insignificantRelativeSizeSpan) {
    s.removeSpan(SIGNIFICANT_SPAN);
    if (insignificantRelativeSizeSpan != null) {
        s.removeSpan(insignificantRelativeSizeSpan);
    }

    final Matcher m = P_SIGNIFICANT.matcher(s);
    if (m.find()) {
        final int pivot = m.group().length();
        s.setSpan(SIGNIFICANT_SPAN, 0, pivot, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (s.length() > pivot && insignificantRelativeSizeSpan != null) {
            s.setSpan(insignificantRelativeSizeSpan, pivot, s.length(), Spannable
                    .SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}
项目:lbry-android    文件:WalletUtils.java   
public static void formatSignificant(@Nonnull final Spannable spannable, @Nullable final RelativeSizeSpan insignificantRelativeSizeSpan)
{
    spannable.removeSpan(SIGNIFICANT_SPAN);
    if (insignificantRelativeSizeSpan != null)
        spannable.removeSpan(insignificantRelativeSizeSpan);

    final Matcher m = P_SIGNIFICANT.matcher(spannable);
    if (m.find())
    {
        final int pivot = m.group().length();
        if (pivot > 0)
            spannable.setSpan(SIGNIFICANT_SPAN, 0, pivot, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (spannable.length() > pivot && insignificantRelativeSizeSpan != null)
            spannable.setSpan(insignificantRelativeSizeSpan, pivot, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
项目:smoothnovelreader    文件:ChangeLogUtils.java   
public CharSequence toSpannable() {
    LinkedList<ChangeLogRow> rows = mChangeLog.getRows();
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
    boolean isFirstRow = true;
    for (ChangeLogRow row : rows) {
        if(row.isHeader()) {
            if(!isFirstRow)
                stringBuilder.append("\n");
            int versionStart = stringBuilder.length();
            int versionEnd = versionStart + row.getVersionName().length();
            stringBuilder.append(row.getVersionName());
            stringBuilder.setSpan(new StyleSpan(Typeface.BOLD), versionStart, versionEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            stringBuilder.setSpan(new RelativeSizeSpan(1.5f), versionStart, versionEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            isFirstRow = false;
        } else {
            CharSequence displayChange = Html.fromHtml(row.getChangeText());
            int changeStart = stringBuilder.length();
            int changeEnd = changeStart + displayChange.length();
            stringBuilder.append("    \u2022  ").append(displayChange);
            //stringBuilder.setSpan(new BulletSpan(15), changeStart, changeEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            //stringBuilder.append("\n");
        }
        stringBuilder.append("\n");
    }
    return stringBuilder;
}
项目:RichEditText    文件:HtmlToSpannedConverter.java   
private static void endHeader(SpannableStringBuilder text)
{
    int len = text.length();
    Object obj = getLast(text, Header.class);

    int where = text.getSpanStart(obj);

    text.removeSpan(obj);

    // Back off not to change only the text, not the blank line.
    while (len > where && text.charAt(len - 1) == '\n') {
        len--;
    }

    if (where != len) {
        Header h = (Header) obj;
        if (h == null) {
            Log.e("endHeader", "h = null");
            return;
        }
        text.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]),
                where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setSpan(new StyleSpan(Typeface.BOLD),
                where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
项目:AyoSunny    文件:HtmlTagHandler.java   
private static void endHeader(SpannableStringBuilder text) {
    int len = text.length();
    Object obj = getLast(text, Header.class);

    int where = text.getSpanStart(obj);

    text.removeSpan(obj);

    // Back off not to change only the text, not the blank line.
    while (len > where && text.charAt(len - 1) == '\n') {
        len--;
    }

    if (where != len) {
        Header h = (Header) obj;

        text.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]),
                where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setSpan(new StyleSpan(Typeface.BOLD),
                where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
项目:Doctor    文件:ConverterHtmlToSpanned.java   
private void endHeader() {
    int len = mResult.length();
    Object obj = getLast(Header.class);

    int where = mResult.getSpanStart(obj);

    mResult.removeSpan(obj);

    // Back off not to change only the text, not the blank line.
    while (len > where && mResult.charAt(len - 1) == '\n') {
        len--;
    }

    if (where != len) {
        Header h = (Header) obj;
        mResult.setSpan(new RelativeSizeSpan(HEADER_SIZES[h.mLevel]), where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mResult.setSpan(new BoldSpan(), where, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
项目:GitHub    文件:PiePolylineChartActivity.java   
private SpannableString generateCenterSpannableText() {

        SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
        s.setSpan(new RelativeSizeSpan(1.5f), 0, 14, 0);
        s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
        s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
        s.setSpan(new RelativeSizeSpan(.65f), 14, s.length() - 15, 0);
        s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
        s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
        return s;
    }
项目:GitHub    文件:HalfPieChartActivity.java   
private SpannableString generateCenterSpannableText() {

        SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
        s.setSpan(new RelativeSizeSpan(1.7f), 0, 14, 0);
        s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
        s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
        s.setSpan(new RelativeSizeSpan(.8f), 14, s.length() - 15, 0);
        s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
        s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
        return s;
    }
项目:GitHub    文件:RealmDatabaseActivityPie.java   
private SpannableString generateCenterSpannableText() {

        SpannableString s = new SpannableString("Realm.io\nmobile database");
        s.setSpan(new ForegroundColorSpan(Color.rgb(240, 115, 126)), 0, 8, 0);
        s.setSpan(new RelativeSizeSpan(2.2f), 0, 8, 0);
        s.setSpan(new StyleSpan(Typeface.ITALIC), 9, s.length(), 0);
        s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 9, s.length(), 0);
        s.setSpan(new RelativeSizeSpan(0.85f), 9, s.length(), 0);
        return s;
    }
项目:GitHub    文件:PieChartItem.java   
private SpannableString generateCenterText() {
    SpannableString s = new SpannableString("MPAndroidChart\ncreated by\nPhilipp Jahoda");
    s.setSpan(new RelativeSizeSpan(1.6f), 0, 14, 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.VORDIPLOM_COLORS[0]), 0, 14, 0);
    s.setSpan(new RelativeSizeSpan(.9f), 14, 25, 0);
    s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, 25, 0);
    s.setSpan(new RelativeSizeSpan(1.4f), 25, s.length(), 0);
    s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 25, s.length(), 0);
    return s;
}
项目:GitHub    文件:PieChartActivity.java   
private SpannableString generateCenterSpannableText() {

        SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
        s.setSpan(new RelativeSizeSpan(1.7f), 0, 14, 0);
        s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
        s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
        s.setSpan(new RelativeSizeSpan(.8f), 14, s.length() - 15, 0);
        s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
        s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
        return s;
    }
项目:GitHub    文件:Utils.java   
public static void setSpannableStr(TextView textView, String str, int startIndex, int endIndex, float proporation) {
    SpannableString spannableString = new SpannableString(str);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#393939"));
    spannableString.setSpan(colorSpan, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    RelativeSizeSpan sizeSpan01 = new RelativeSizeSpan(proporation);
    spannableString.setSpan(sizeSpan01, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

    textView.setText(spannableString);
}
项目:mapbox-navigation-android    文件:TimeUtils.java   
public static SpannableStringBuilder formatTimeRemaining(double routeDuration) {
  long seconds = (long) routeDuration;

  if (seconds < 0) {
    throw new IllegalArgumentException("Duration must be greater than zero.");
  }

  long days = TimeUnit.SECONDS.toDays(seconds);
  seconds -= TimeUnit.DAYS.toSeconds(days);
  long hours = TimeUnit.SECONDS.toHours(seconds);
  seconds -= TimeUnit.HOURS.toSeconds(hours);
  long minutes = TimeUnit.SECONDS.toMinutes(seconds);
  seconds -= TimeUnit.MINUTES.toSeconds(minutes);

  if (seconds >= 30) {
    minutes = minutes + 1;
  }

  List<SpanItem> spanItems = new ArrayList<>();
  if (days != 0) {
    String dayFormat = days > 1 ? DAYS : DAY;
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(days)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), dayFormat));
  }
  if (hours != 0) {
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(hours)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), HOUR));
  }
  if (minutes != 0) {
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(minutes)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), MINUTE));
  }
  if (days == 0 && hours == 0 && minutes == 0) {
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(1)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), MINUTE));
  }

  return SpanUtils.combineSpans(spanItems);
}
项目:PeSanKita-android    文件:MessageRecord.java   
protected SpannableString emphasisAdded(String sequence) {
  SpannableString spannable = new SpannableString(sequence);
  spannable.setSpan(new RelativeSizeSpan(0.9f), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  spannable.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

  return spannable;
}
项目:markor    文件:Highlighter.java   
protected void clearSpans(Editable editable) {
    clearCharacterSpanType(editable, TextAppearanceSpan.class);
    clearCharacterSpanType(editable, ForegroundColorSpan.class);
    clearCharacterSpanType(editable, BackgroundColorSpan.class);
    clearCharacterSpanType(editable, StrikethroughSpan.class);
    clearCharacterSpanType(editable, RelativeSizeSpan.class);
    clearCharacterSpanType(editable, StyleSpan.class);
    clearCharacterSpanType(editable, ColorUnderlineSpan.class);
    clearParagraphSpanType(editable, LineBackgroundSpan.class);
    clearParagraphSpanType(editable, LineHeightSpan.class);
}
项目:SpanEZ    文件:SpanEZTest.java   
@Test
public void relative_size_should_add_only_one_span() {
    spanBuilder.relativeSize(range, INTEGER_ARG)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(RelativeSizeSpan.class));
}
项目:MyBP    文件:Span.java   
public static void span(String text, String subText, Switch switchView) {
    SpannableString spanText = new SpannableString(text);
    spanText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, text.length(), 0);
    spanText.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), 0);

    SpannableString spanSubText = new SpannableString(subText);
    spanSubText.setSpan(new RelativeSizeSpan(0.75f), 0, subText.length(), 0);
    spanSubText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, subText.length(), 0);
    switchView.setText("");
    switchView.append(spanText);
    switchView.append("\n");
    switchView.append(spanSubText);
}
项目:MyBP    文件:Span.java   
public static void span(String text, String subText, TextView textView) {
    SpannableString spanText = new SpannableString(text);
    spanText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, text.length(), 0);
    spanText.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), 0);

    SpannableString spanSubText = new SpannableString(subText);
    spanSubText.setSpan(new RelativeSizeSpan(0.75f), 0, subText.length(), 0);
    spanSubText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, subText.length(), 0);
    textView.setText("");
    textView.append(spanText);
    textView.append("\n");
    textView.append(spanSubText);
}
项目:JewelryUI    文件:MainActivity.java   
private void setSpannableText(String src) {
    //tvName.setText(src);
    String temp = src.replace("\n", " ");
    List<Integer> mList = new ArrayList<>();
    int index = 0;
    int max = 0;
    if (temp.indexOf(" ", index) > 0) {
        while (temp.indexOf(" ", index) > 0 || index >= temp.length() || max < 50) {
            max++;
            index = temp.indexOf(" ", index);
            if (index <0 ) {
                break;
            } else {
                //Log.e(TAG, "空格位置: " + String.valueOf(index));
                mList.add(index);
                index++;
            }
        }
    }
    SpannableString spannable = new SpannableString(src);
    spannable.setSpan(new RelativeSizeSpan(1.5f), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (mList.size() > 0) {
        for (int i = 0; i < mList.size(); i++) {
            int position = mList.get(i) + 1;
            //Log.e(TAG, "变更样式位置: " + String.valueOf(position));
            spannable.setSpan(new RelativeSizeSpan(1.5f), position, position + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
    tvName.setText(spannable);
}
项目:Mix    文件:OrderDialogFragment.java   
@BindingAdapter("app:spanOffset")
public static void setItemSpan(View v, int spanOffset) {
    final String itemText = ((TextView) v).getText().toString();
    final SpannableString sString = new SpannableString(itemText);

    sString.setSpan(new RelativeSizeSpan(1.65f), itemText.length() - spanOffset, itemText.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    ((TextView) v).setText(sString);
}
项目:amap    文件:MIP_TextStyle.java   
public MIP_TextStyle setRelativeSize(float size, int start, int end)
{
    if (spannableString == null)
    {
        return this;
    }
    spannableString.setSpan(new RelativeSizeSpan(size), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 0.5f表示默认字体大小的一半
    return this;
}
项目:DateRangePickerLibrary    文件:SampleDecorator.java   
@Override
public void decorate(CalendarCellView cellView, Date date) {
  String dateString = Integer.toString(date.getDate());
  SpannableString string = new SpannableString(dateString + "\ntitle");
  string.setSpan(new RelativeSizeSpan(0.5f), 0, dateString.length(),
      Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
  cellView.getDayOfMonthTextView().setText(string);
}
项目:From-design-to-Android-part1    文件:OrderDialogFragment.java   
@BindingAdapter("app:spanOffset")
public static void setItemSpan(View v, int spanOffset) {
    final String itemText = ((TextView) v).getText().toString();
    final SpannableString sString = new SpannableString(itemText);

    sString.setSpan(new RelativeSizeSpan(1.65f), itemText.length() - spanOffset, itemText.length(),
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    ((TextView) v).setText(sString);
}
项目:mvvm-template    文件:HeaderHandler.java   
@Override
public void handleTagNode(TagNode tagNode, SpannableStringBuilder builder, int start, int end) {
    builder.setSpan(new RelativeSizeSpan(this.size), start, end, 33);
    FontFamilySpan originalSpan = this.getFontFamilySpan(builder, start, end);
    FontFamilySpan boldSpan;
    if (originalSpan == null) {
        boldSpan = new FontFamilySpan(getSpanner().getDefaultFont());
    } else {
        boldSpan = new FontFamilySpan(originalSpan.getFontFamily());
        boldSpan.setItalic(originalSpan.isItalic());
    }
    boldSpan.setBold(true);
    builder.setSpan(boldSpan, start, end, 33);
    appendNewLine(builder);
}