List of usage examples for android.text.style ForegroundColorSpan ForegroundColorSpan
public ForegroundColorSpan(@NonNull Parcel src)
From source file:de.schildbach.wallet.ui.CurrencyTextView.java
public void setPrefixColor(final int prefixColor) { this.prefixColorSpan = new ForegroundColorSpan(prefixColor); updateView();/*w w w . j a v a 2 s .co m*/ }
From source file:cat.mvmike.minimalcalendarwidget.service.DayService.java
private static void setInstanceNumber(final Context context, final RemoteViews cellRv, final String dayOfMonth, final boolean isToday, final int found) { Symbol symbols = ConfigurationService.getInstancesSymbols(context); Character[] symbolArray = symbols.getArray(); int max = symbolArray.length - 1; String symbol = String.valueOf(found > max ? symbolArray[max] : symbolArray[found]); String dayOfMonthSpSt = PADDING + (dayOfMonth.length() == 1 ? dayOfMonth + DOUBLE_PADDING : dayOfMonth) + PADDING + symbol;//from www . j ava 2s.c o m SpannableString daySpSt = new SpannableString(dayOfMonthSpSt); daySpSt.setSpan(new StyleSpan(Typeface.BOLD), dayOfMonthSpSt.length() - 1, dayOfMonthSpSt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); int color; if (isToday) { color = ContextCompat.getColor(context, R.color.instances_today); daySpSt.setSpan(new StyleSpan(Typeface.BOLD), 0, dayOfMonthSpSt.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { color = ContextCompat.getColor(context, ConfigurationService.getInstancesSymbolsColours(context).getHexValue()); } daySpSt.setSpan(new ForegroundColorSpan(color), dayOfMonthSpSt.length() - 1, dayOfMonthSpSt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); daySpSt.setSpan(new RelativeSizeSpan(symbols.getRelativeSize()), dayOfMonthSpSt.length() - 1, dayOfMonthSpSt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); cellRv.setTextViewText(android.R.id.text1, daySpSt); }
From source file:org.solovyev.android.calculator.App.java
@NonNull public static SpannableString colorString(@Nonnull String s, int color) { final SpannableString spannable = new SpannableString(s); spannable.setSpan(new ForegroundColorSpan(color), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spannable; }
From source file:org.mariotaku.twidere.view.NameView.java
public void setPrimaryTextColor(final int color) { mPrimaryTextColor = new ForegroundColorSpan(color); }
From source file:org.mariotaku.twidere.view.NameView.java
public void setSecondaryTextColor(final int color) { mSecondaryTextColor = new ForegroundColorSpan(color); }
From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsSuccessFragment.java
private void initView(View view) { if (requsetData != null) { TextView tv_content = (TextView) view.findViewById(R.id.tv_content); String s1 = "????"; String s2 = requsetData.getValue("fumobile"); String s3 = "??"; String s4 = "" + requsetData.getValue("money"); String s5 = ",??1"; String content = s1 + s2 + s3 + s4 + s5; int len = 0; /**// w ww .j av a 2s .co m * ?TEXTVIEW?? */ SpannableString ss = new SpannableString(content); ss.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.agent_apply_yellow)), len = s1.length() + s2.length() + s3.length(), len + s4.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tv_content.setText(ss); tv_content.setMovementMethod(LinkMovementMethod.getInstance()); // String content = "????" // +requsetData.getValue("fumobile") // +"??" // +requsetData.getValue("money") // +",??1"; // tv_content.setText(content); TextView tv_shou_bank = (TextView) view.findViewById(R.id.tv_shou_bank); String shou_bank = "" + requsetData.getValue("shoucardbank"); tv_shou_bank.setText(shou_bank); TextView tv_shou_card = (TextView) view.findViewById(R.id.tv_shou_card); String shou_card = "?" + requsetData.getValue("shoucardno"); tv_shou_card.setText(shou_card); } Button see_history = (Button) view.findViewById(R.id.see_history); see_history.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub getActivity().setResult(Constants.ACTIVITY_FINISH); getActivity().finish(); } }); Button btnAgain = (Button) view.findViewById(R.id.btn_again); btnAgain.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { /** * ?? */ SmsReceivePaymentMainFragment.isComeBackFromPaySuccess = true; Intent intent = new Intent(getActivity(), IndexActivity.class); intent.putExtra(FragmentFactory.INDEX_KEY, FuncMap.SMSRECEIPT_INDEX_FUNC); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); }
From source file:com.example.textviewsample.MainActivityFragment.java
private void styleSourceCode() { TypefaceSpan codeSpan = new TypefaceSpan(getActivity(), "SourceCodePro-Regular"); TypefaceSpan codeSpan2 = new TypefaceSpan(getActivity(), "SourceCodePro-Bold", Typeface.BOLD); ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.MAGENTA); ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(Color.BLUE); SpannableString title = new SpannableString(getString(R.string.code_sample)); title.setSpan(codeSpan, 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); title.setSpan(codeSpan2, 19, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); title.setSpan(colorSpan, 4, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); title.setSpan(colorSpan2, 19, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sourceCodeText.setText(title);/*from w w w . j av a 2s . com*/ }
From source file:de.vanita5.twittnuker.activity.support.ThemedFragmentActivity.java
@Override protected void onTitleChanged(CharSequence title, int color) { final SpannableStringBuilder builder = new SpannableStringBuilder(title); final int themeResId = getCurrentThemeResourceId(); final int themeColor = getThemeColor(), contrastColor = ColorUtils.getContrastYIQ(themeColor, 192); if (!ThemeUtils.isDarkTheme(themeResId)) { builder.setSpan(new ForegroundColorSpan(contrastColor), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }/*from w ww . ja v a 2s .c o m*/ super.onTitleChanged(title, color); }
From source file:com.ymt.demo1.main.sign.SignUpFragment.java
/** * ???/*from w w w.j a v a2s . c om*/ * ????????? */ protected void initView(View view) { /* */ //? final EditText phoneTxt = (EditText) view.findViewById(R.id.input_phone_num); final EditText accountTxt = (EditText) view.findViewById(R.id.input_account); final EditText pswTxt = (EditText) view.findViewById(R.id.input_psw); final EditText rePswTxt = (EditText) view.findViewById(R.id.re_input_psw); final TextView licenseTxt = (TextView) view.findViewById(R.id.licence_txt); /*???? ?? */ final TextView getCheckNums = (TextView) view.findViewById(R.id.get_check_nums); final EditText inputCheckNums = (EditText) view.findViewById(R.id.input_check_nums); getCheckNums.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //todo ???? } }); /** * todo spannableString * ? */ SpannableString spannableString = new SpannableString(getString(R.string.license)); ForegroundColorSpan span = new ForegroundColorSpan(getResources().getColor(R.color.material_blue_grey_800)); spannableString.setSpan(span, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); licenseTxt.setText(spannableString); //switch(??) myCheckView = (MyCheckView) view.findViewById(R.id.switch_liscense); // Button signUpBtn = (Button) view.findViewById(R.id.do_sign_btn); signUpBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // String phoneNum = phoneTxt.getText().toString(); String account = accountTxt.getText().toString(); String psw = pswTxt.getText().toString(); String rePsw = rePswTxt.getText().toString(); //?? String checkNums = inputCheckNums.getText().toString(); //todo if(){}else{} ?? if (!TextUtils.isEmpty(phoneNum) && !TextUtils.isEmpty(account) && !TextUtils.isEmpty(psw) && psw.equals(rePsw)) { //? if (myCheckView.isChecked()) { queue.add(signUpRequest(account, psw, phoneNum, NORMAL_USER)); } else { Toast.makeText(getActivity(), "?????", Toast.LENGTH_SHORT).show(); } } else if (TextUtils.isEmpty(phoneNum)) { //??? Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show(); } else if (TextUtils.isEmpty(account)) { //??? Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show(); } else { //??? Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT) .show(); } } }); LinearLayout licence = (LinearLayout) view.findViewById(R.id.liscense_layout); licence.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myCheckView.callOnClick(); } }); }
From source file:eltos.simpledialogfragments.FlatFragmentActivity.java
/** * Let the hosting fragment or activity implement this interface * to receive results from the dialog/* w ww . j a v a 2s .c o m*/ * * @param dialogTag the tag passed to {@link SimpleDialog#show} * @param which result type, one of {@link #BUTTON_POSITIVE}, {@link #BUTTON_NEGATIVE}, * {@link #BUTTON_NEUTRAL} or {@link #CANCELED} * @param extras the extras passed to {@link SimpleDialog#extra(Bundle)} * @return true if the result was handled, false otherwise */ @Override public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) { // handle results as usual if (COLOR_FRAGMENT.equals(dialogTag) && which == BUTTON_POSITIVE) { @ColorInt int color = extras.getInt(SimpleColorDialog.COLOR); // Sets action bar colors if (getSupportActionBar() != null) { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFF000000 | color)); boolean dark = Color.red(color) * 0.299 + Color.green(color) * 0.587 + Color.blue(color) * 0.114 < 180; SpannableString s = new SpannableString(getSupportActionBar().getTitle()); s.setSpan(new ForegroundColorSpan(dark ? Color.WHITE : Color.BLACK), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getSupportActionBar().setTitle(s); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= 0.75; getWindow().setStatusBarColor(Color.HSVToColor(hsv)); } return true; } return false; }