use of android.text.style.ForegroundColorSpan in project android_frameworks_base by crdroidandroid.
the class ViewPropertyAlphaActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_properties);
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
startAnim(R.id.button);
startAnim(R.id.textview);
startAnim(R.id.spantext);
startAnim(R.id.edittext);
startAnim(R.id.selectedtext);
startAnim(R.id.textviewbackground);
startAnim(R.id.layout);
startAnim(R.id.imageview);
startAnim(myViewAlphaDefault);
startAnim(myViewAlphaHandled);
EditText selectedText = (EditText) findViewById(R.id.selectedtext);
selectedText.setSelection(3, 8);
}
}, 2000);
Button invalidator = (Button) findViewById(R.id.invalidateButton);
invalidator.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.textview).invalidate();
findViewById(R.id.spantext).invalidate();
}
});
TextView textView = (TextView) findViewById(R.id.spantext);
if (textView != null) {
SpannableStringBuilder text = new SpannableStringBuilder("Now this is a short text message with spans");
text.setSpan(new BackgroundColorSpan(Color.RED), 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ForegroundColorSpan(Color.BLUE), 4, 9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new SuggestionSpan(this, new String[] { "longer" }, 3), 11, 16, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new UnderlineSpan(), 17, 20, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ImageSpan(this, R.drawable.icon), 21, 22, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(text);
}
LinearLayout container = (LinearLayout) findViewById(R.id.container);
myViewAlphaDefault = new MyView(this, false);
myViewAlphaDefault.setLayoutParams(new LinearLayout.LayoutParams(75, 75));
container.addView(myViewAlphaDefault);
myViewAlphaHandled = new MyView(this, true);
myViewAlphaHandled.setLayoutParams(new LinearLayout.LayoutParams(75, 75));
container.addView(myViewAlphaHandled);
}
use of android.text.style.ForegroundColorSpan in project android_frameworks_base by AOSPA.
the class HtmlToSpannedConverter method endFont.
private static void endFont(Editable text) {
Font font = getLast(text, Font.class);
if (font != null) {
setSpanFromMark(text, font, new TypefaceSpan(font.mFace));
}
Foreground foreground = getLast(text, Foreground.class);
if (foreground != null) {
setSpanFromMark(text, foreground, new ForegroundColorSpan(foreground.mForegroundColor));
}
}
use of android.text.style.ForegroundColorSpan in project android_frameworks_base by AOSPA.
the class CustomTile method handleUpdateState.
@Override
protected void handleUpdateState(State state, Object arg) {
int tileState = mTile.getState();
if (mServiceManager.hasPendingBind()) {
tileState = Tile.STATE_UNAVAILABLE;
}
Drawable drawable;
boolean mHasRes = false;
android.graphics.drawable.Icon icon = mTile.getIcon();
try {
drawable = icon.loadDrawable(mAppContext);
mHasRes = icon.getType() == android.graphics.drawable.Icon.TYPE_RESOURCE;
} catch (Exception e) {
Log.w(TAG, "Invalid icon, forcing into unavailable state");
tileState = Tile.STATE_UNAVAILABLE;
drawable = mDefaultIcon.loadDrawable(mAppContext);
}
int color = mContext.getColor(getColor(tileState));
drawable.setTint(color);
state.icon = mHasRes ? new DrawableIconWithRes(drawable, icon.getResId()) : new DrawableIcon(drawable);
state.label = mTile.getLabel();
if (tileState == Tile.STATE_UNAVAILABLE) {
state.label = new SpannableStringBuilder().append(state.label, new ForegroundColorSpan(mContext.getColor(R.color.qs_tile_label_tint_unavailable)), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
}
if (mTile.getContentDescription() != null) {
state.contentDescription = mTile.getContentDescription();
} else {
state.contentDescription = state.label;
}
}
use of android.text.style.ForegroundColorSpan in project AgentWeb by Justson.
the class AgentWebUtils method show.
public 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();
}
use of android.text.style.ForegroundColorSpan in project BookReader by JustWayward.
the class BookMarkAdapter method convert.
@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", ""));
}
}
Aggregations