当前位置: 首页>>代码示例>>Java>>正文


Java ForegroundColorSpan类代码示例

本文整理汇总了Java中android.text.style.ForegroundColorSpan的典型用法代码示例。如果您正苦于以下问题:Java ForegroundColorSpan类的具体用法?Java ForegroundColorSpan怎么用?Java ForegroundColorSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ForegroundColorSpan类属于android.text.style包,在下文中一共展示了ForegroundColorSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDesignationText

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
public SpannableString getDesignationText()
{
    String text = txtDesignation.getText().toString();

    SpannableString s = new SpannableString(text);

    s.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorAccent)), text.indexOf("@"), text.length(), 0);

    /*
    s.setSpan(new RelativeSizeSpan(1.2f), text.indexOf("A"), text.length(), 0);
    s.setSpan(new StyleSpan(Typeface.NORMAL), text.indexOf("A"), text.length(), 0);
    s.setSpan(new ForegroundColorSpan(Color.BLACK), text.indexOf("A"), text.length(), 0);
    */

    return s;
}
 
开发者ID:wajahatkarim3,项目名称:Quizca-UI-Concept,代码行数:17,代码来源:MainActivity.java

示例2: onBindViewHolder

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override
public void onBindViewHolder(ResultViewHolder viewHolder, int position) {
    SearchItem item = mResultList.get(position);

    viewHolder.icon_left.setImageResource(item.get_icon());
    viewHolder.icon_left.setColorFilter(SearchView.getIconColor(), PorterDuff.Mode.SRC_IN);
    viewHolder.text.setTypeface((Typeface.create(SearchView.getTextFont(), SearchView.getTextStyle())));
    viewHolder.text.setTextColor(SearchView.getTextColor());

    String itemText = item.get_text().toString();
    String itemTextLower = itemText.toLowerCase(Locale.getDefault());

    if (itemTextLower.contains(key) && !key.isEmpty()) {
        SpannableString s = new SpannableString(itemText);
        s.setSpan(new ForegroundColorSpan(SearchView.getTextHighlightColor()), itemTextLower.indexOf(key), itemTextLower.indexOf(key) + key.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        viewHolder.text.setText(s, TextView.BufferType.SPANNABLE);
    } else {
        viewHolder.text.setText(item.get_text());
    }
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:21,代码来源:SearchAdapter.java

示例3: highlightText

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
private Spannable highlightText(String text) {
    Spannable highlightedSpannable = Spannable.Factory.getInstance().newSpannable(text);

    if (highlight == null) {
        return highlightedSpannable;
    }

    Pattern pattern = Pattern.compile(highlight, Pattern.LITERAL | Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(text);
    while (matcher.find()) {
        highlightedSpannable.setSpan(
                new ForegroundColorSpan(context.getResources().getColor(android.R.color.holo_blue_light)),
                matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    return highlightedSpannable;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:18,代码来源:RecipientAdapter.java

示例4: setCheckInUI

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
private void setCheckInUI(int count, boolean isChecked) {
    boolean z;
    String message = String.format(getString(R.string.d7), new Object[]{Integer.valueOf
            (count)});
    SpannableString ss = new SpannableString(message);
    ss.setSpan(new ForegroundColorSpan(SupportMenu.CATEGORY_MASK), 5, message.length() - 1, 33);
    this.checkInMsgText.setText(ss);
    this.checkInBtn.setText(isChecked ? R.string.d4 : R.string.d6);
    TextView textView = this.checkInBtn;
    if (isChecked) {
        z = false;
    } else {
        z = true;
    }
    textView.setEnabled(z);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:StatusBlockFragment.java

示例5: highlightParamTextOffsetRightOne

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
public static SpannableString highlightParamTextOffsetRightOne(String inputString, String highlight, int color) {
    inputString = String.format(inputString, new Object[]{highlight});
    SpannableString spanString = new SpannableString(inputString);
    if (!TextUtils.isEmpty(inputString)) {
        int beginPos = inputString.indexOf(highlight);
        if (beginPos > -1) {
            int endPos;
            if ((highlight.length() + beginPos) + 1 > inputString.length()) {
                endPos = inputString.length();
            } else {
                endPos = (highlight.length() + beginPos) + 1;
            }
            spanString.setSpan(new ForegroundColorSpan(color), beginPos, endPos, 33);
        }
    }
    return spanString;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:StringUtils.java

示例6: internalUpdate

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override
protected void internalUpdate(XySeriesInfo seriesInfo) {
    final SpannableStringBuilder sb = new SpannableStringBuilder();
    sb.append(modifierName).append(StringUtil.NEW_LINE);

    if (seriesInfo.seriesName != null) {
        sb.append(seriesInfo.seriesName);
        sb.setSpan(new ForegroundColorSpan(ColorUtil.Black), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.append(StringUtil.NEW_LINE);
    }

    sb.append("X: ").append(seriesInfo.getFormattedXValue());
    sb.append(" Y: ").append(seriesInfo.getFormattedYValue());

    setText(sb);

    // stroke 0xffff4500
    setSeriesColor(0xffe2460c);
}
 
开发者ID:ABTSoftware,项目名称:SciChart.Android.Examples,代码行数:20,代码来源:CustomTooltipsWithModifiersFragment.java

示例7: convert

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override
public void convert(EasyLVHolder holder, int position, BookMark item) {
    TextView tv = holder.getView(R.id.tvMarkItem);

    SpannableString spanText = new SpannableString((position + 1) + ". " + item.title + ": ");
    spanText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext, R.color.light_coffee)),
            0, spanText.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

    tv.setText(spanText);

    if (item.desc != null) {
        tv.append(item.desc
                .replaceAll(" ", "")
                .replaceAll(" ", "")
                .replaceAll("\n", ""));
    }

}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:19,代码来源:BookMarkAdapter.java

示例8: getHighLightKeyWord

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
/** 
    * @param color 关键字颜色 
    * @param text 文本 
    * @param keyword 多个关键字 
    * @return 
    */  
   public static SpannableString getHighLightKeyWord(int color, String text, String[] keyword)
{  
       SpannableString s = new SpannableString(text);  
       for (int i = 0; i < keyword.length; i++)
	{  
           Pattern p = Pattern.compile(keyword[i]);  
           Matcher m = p.matcher(s);  
           while (m.find())
		{  
               int start = m.start();  
               int end = m.end();  
               s.setSpan(new ForegroundColorSpan(color), start, end, 
					  Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  
           }  
       }  
       return s;  

   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:25,代码来源:HighLightKeyWordUtil.java

示例9: setFeeValue

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override
    public void setFeeValue(Fee fee) {
        if (fee != null || 1 == getIntent().getIntExtra("type", OrderStatus.ORDER_STATUS_DETAIL)) {
            totalAmount = fee.getMoney().getTotalAmount();
            if (mOrderDetail.getCouponList() == null || mOrderDetail.getCouponList().getCoupon() == null || mOrderDetail.getCouponList().getCoupon().getName().equals("")) {
                mTextView_Coupon_Value.setText("有" + fee.getCouponNumber() + "张可用");
            }
//            mTextView_Fee.setText("运费:" + CommonUtils.doubleFormat(fee.getMoney().getTotalAmount()));

            SpannableString styledText = new SpannableString("运费:¥"+CommonUtils.doubleFormat(fee.getMoney().getTotalAmount()));
            int color = getResources().getColor(R.color.my_yellow);
            styledText.setSpan(new ForegroundColorSpan(color), 0, 3, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            mTextView_Fee.setText(styledText);

            mOrderDetail.setValueAddedlist(fee.getValueAddedlist());
            this.fee = fee.getMoney().getTotalAmount();
        }
    }
 
开发者ID:Zyj163,项目名称:yyox,代码行数:19,代码来源:OrderDetailActivity.java

示例10: bind

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
public void bind(ServerLogsEntry entry, int pos) {
    int colorId = R.color.storageSettingsChartOthers;
    if (entry.size > 0L) {
        if (pos == 0)
            colorId = R.color.storageSettingsChartFirst;
        else if (pos == 1)
            colorId = R.color.storageSettingsChartSecond;
        else if (pos == 2)
            colorId = R.color.storageSettingsChartThird;
    }
    ColoredTextBuilder builder = new ColoredTextBuilder();
    builder.append(entry.name, new ForegroundColorSpan(mText.getResources().getColor(colorId)));
    builder.append("  ");
    builder.append(formatFileSize(entry.size));
    mText.setText(builder.getSpannable());
    mText.setTag(entry.uuid);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:18,代码来源:StorageSettingsAdapter.java

示例11: onBindViewHolder

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override
protected void onBindViewHolder(@NonNull IOSItemBinder.ViewHolder viewHolder,
                                @NonNull IOS ios) {
    SpannableString span = new SpannableString(new StringBuilder()
            .append(ios.content)
            .append("(via-")
            .append(ios.author)
            .append(")"));
    span.setSpan(new ForegroundColorSpan(Color.parseColor("#9e9e9e"))
            , ios.content.length()
            , span.length()
            , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    viewHolder.content.setText(span);
    viewHolder.url = ios.url;
    viewHolder.title = ios.content;
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:17,代码来源:IOSItemBinder.java

示例12: show

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
static void show(View parent,
                 CharSequence text,
                 int duration,
                 @ColorInt int textColor,
                 @ColorInt int bgColor,
                 CharSequence actionText,
                 @ColorInt int actionTextColor,
                 View.OnClickListener listener) {
    SpannableString spannableString = new SpannableString(text);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(textColor);
    spannableString.setSpan(colorSpan, 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    snackbarWeakReference = new WeakReference<>(Snackbar.make(parent, spannableString, duration));
    Snackbar snackbar = snackbarWeakReference.get();
    View view = snackbar.getView();
    view.setBackgroundColor(bgColor);
    if (actionText != null && actionText.length() > 0 && listener != null) {
        snackbar.setActionTextColor(actionTextColor);
        snackbar.setAction(actionText, listener);
    }
    snackbar.show();

}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:23,代码来源:AgentWebUtils.java

示例13: handleMidrowCtrl

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
private void handleMidrowCtrl(byte cc2) {
  // TODO: support the extended styles (i.e. backgrounds and transparencies)

  // cc2 - 0|0|1|0|ATRBT|U
  // ATRBT is the 3-byte encoded attribute, and U is the underline toggle
  boolean isUnderlined = (cc2 & 0x01) == 0x01;
  currentCueBuilder.setUnderline(isUnderlined);

  int attribute = (cc2 >> 1) & 0x0F;
  if (attribute == 0x07) {
    currentCueBuilder.setMidrowStyle(new StyleSpan(Typeface.ITALIC), 2);
    currentCueBuilder.setMidrowStyle(new ForegroundColorSpan(Color.WHITE), 1);
  } else {
    currentCueBuilder.setMidrowStyle(new ForegroundColorSpan(COLORS[attribute]), 1);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:17,代码来源:Cea608Decoder.java

示例14: handleTagNode

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
    if (isPre) {
        StringBuffer buffer = new StringBuffer();
        buffer.append("\n");//fake padding top + make sure, pre is always by itself
        getPlainText(buffer, node);
        buffer.append("\n");//fake padding bottom + make sure, pre is always by itself
        builder.append(replace(buffer.toString()));
        builder.append("\n");
        builder.setSpan(new CodeBackgroundRoundedSpan(color), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.append("\n");
        this.appendNewLine(builder);
        this.appendNewLine(builder);
    } else {
        StringBuffer text = node.getText();
        builder.append(" ");
        builder.append(replace(text.toString()));
        builder.append(" ");
        final int stringStart = start + 1;
        final int stringEnd = builder.length() - 1;
        builder.setSpan(new BackgroundColorSpan(color), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE);
        if (theme == PrefGetter.LIGHT) {
            builder.setSpan(new ForegroundColorSpan(Color.RED), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        builder.setSpan(new TypefaceSpan("monospace"), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:27,代码来源:PreTagHandler.java

示例15: createColorPicker

import android.text.style.ForegroundColorSpan; //导入依赖的package包/类
@Override
protected ColorListPickerDialog createColorPicker(boolean fillColor, int selectedColor) {
    ColorListPickerDialog ret = super.createColorPicker(fillColor, selectedColor);
    if (!fillColor) {
        ret.setColors(getResources().getIntArray(R.array.formatTextColors), -1);
        ret.setSelectedColor(selectedColor);
        ret.setNeutralButton(R.string.message_format_sender_color,
                (DialogInterface dialog, int which) -> {
                    setSpan(new MessageBuilder.MetaForegroundColorSpan(getContext(),
                            MessageBuilder.MetaForegroundColorSpan.COLOR_SENDER));
                });
        ret.setOnColorChangeListener((ColorListPickerDialog d, int newColorIndex, int color) -> {
            removeSpan(ForegroundColorSpan.class);
            if (color == IRCColorUtils.getStatusTextColor(getContext()))
                setSpan(new MessageBuilder.MetaForegroundColorSpan(getContext(), MessageBuilder.MetaForegroundColorSpan.COLOR_STATUS));
            if (color == IRCColorUtils.getTimestampTextColor(getContext()))
                setSpan(new MessageBuilder.MetaForegroundColorSpan(getContext(), MessageBuilder.MetaForegroundColorSpan.COLOR_TIMESTAMP));
            else
                setSpan(new ForegroundColorSpan(color));
            d.cancel();
        });
    }
    return ret;
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:25,代码来源:MessageFormatSettingsFormatBar.java


注:本文中的android.text.style.ForegroundColorSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。