本文整理汇总了Java中android.text.style.RelativeSizeSpan类的典型用法代码示例。如果您正苦于以下问题:Java RelativeSizeSpan类的具体用法?Java RelativeSizeSpan怎么用?Java RelativeSizeSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelativeSizeSpan类属于android.text.style包,在下文中一共展示了RelativeSizeSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeResources
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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);
}
示例2: getViewAt
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
@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;
}
示例3: setHint
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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));
}
}
示例4: onBindViewHolder
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
@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());
}
示例5: handleMessage
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
@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;
}
}
示例6: spannerbleTitleForHeaderInSection
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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;
}
示例7: endCssStyle
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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()));
}
}
示例8: setHint
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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));
}
}
示例9: getSpannablePriceTotalText
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
/**
* 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;
}
示例10: setPenAttr
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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;
}
}
示例11: endHeader
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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);
}
}
示例12: initializeResources
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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);
}
示例13: onTranslationChanged
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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();
}
});
}
示例14: processSup
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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);
//}
}
}
示例15: formatSignificant
import android.text.style.RelativeSizeSpan; //导入依赖的package包/类
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);
}
}
}