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


Java TypefaceSpan类代码示例

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


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

示例1: initializeResources

import android.text.style.TypefaceSpan; //导入依赖的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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:23,代码来源:PassphrasePromptActivity.java

示例2: handleTag

import android.text.style.TypefaceSpan; //导入依赖的package包/类
@Override
public void handleTag(final boolean opening, final String tag, Editable output, final XMLReader xmlReader) {

    if (tag.equals("ul") || tag.equals("ol") || tag.equals("dd")) {
        if (opening) {
            mListParents.add(tag);
        } else mListParents.remove(tag);

        mListItemCount = 0;
    } else if (tag.equals("li") && !opening) {
        handleListTag(output);
    }
    else if(tag.equalsIgnoreCase("code")) {
        if(opening) {
            output.setSpan(new TypefaceSpan("monospace"), output.length(), output.length(), Spannable.SPAN_MARK_MARK);
        } else {
            Log.d("COde Tag","Code tag encountered");
            Object obj = getLast(output, TypefaceSpan.class);
            int where = output.getSpanStart(obj);

            output.setSpan(new TypefaceSpan("monospace"), where, output.length(), 0);
        }
    }

}
 
开发者ID:afiqiqmal,项目名称:My-Android-Base-Code,代码行数:26,代码来源:HtmlTagHandler.java

示例3: handleTagNode

import android.text.style.TypefaceSpan; //导入依赖的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

示例4: showDialog

import android.text.style.TypefaceSpan; //导入依赖的package包/类
@Override
public void showDialog(Activity activity) {
    super.showDialog(activity);
    dismissDialog(activity);
    ThemedAlertDialog.Builder dialog = new ThemedAlertDialog.Builder(activity);
    dialog.setTitle(R.string.connection_error_command_title);

    StringBuilder commands = new StringBuilder();
    for (String cmd : mCommands) {
        commands.append('/');
        commands.append(cmd);
        commands.append('\n');
    }
    SpannableString commandsSeq = new SpannableString(commands);
    commandsSeq.setSpan(new TypefaceSpan("monospace"), 0, commandsSeq.length(),
            SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
    dialog.setMessage(SpannableStringHelper.format(activity.getResources().getQuantityText(
            R.plurals.connection_error_command_dialog_content, mCommands.size()),
            mNetworkName, commandsSeq));
    dialog.setPositiveButton(R.string.action_ok, null);
    dialog.setOnDismissListener((DialogInterface di) -> {
        dismiss();
    });
    mDialog = dialog.show();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:26,代码来源:UserAutoRunCommandHelper.java

示例5: formatHash

import android.text.style.TypefaceSpan; //导入依赖的package包/类
public static Editable formatHash(@Nullable final String prefix, final String address, final int groupSize,
                                  final int lineSize, final char groupSeparator) {
    final SpannableStringBuilder builder = prefix != null ? new SpannableStringBuilder(prefix)
            : new SpannableStringBuilder();

    final int len = address.length();
    for (int i = 0; i < len; i += groupSize) {
        final int end = i + groupSize;
        final String part = address.substring(i, end < len ? end : len);

        builder.append(part);
        builder.setSpan(new TypefaceSpan("monospace"), builder.length() - part.length(), builder.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (end < len) {
            final boolean endOfLine = lineSize > 0 && end % lineSize == 0;
            builder.append(endOfLine ? '\n' : groupSeparator);
        }
    }

    return builder;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:22,代码来源:WalletUtils.java

示例6: onActivityResult

import android.text.style.TypefaceSpan; //导入依赖的package包/类
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            final String txHash = BitcoinIntegration.transactionHashFromResult(data);
            if (txHash != null) {
                final SpannableStringBuilder messageBuilder = new SpannableStringBuilder("Transaction hash:\n");
                messageBuilder.append(txHash);
                messageBuilder.setSpan(new TypefaceSpan("monospace"), messageBuilder.length() - txHash.length(),
                        messageBuilder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

                if (BitcoinIntegration.paymentFromResult(data) != null)
                    messageBuilder.append("\n(also a BIP70 payment message was received)");

                donateMessage.setText(messageBuilder);
                donateMessage.setVisibility(View.VISIBLE);
            }

            Toast.makeText(this, "Thank you!", Toast.LENGTH_LONG).show();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Toast.makeText(this, "Cancelled.", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Unknown result.", Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:27,代码来源:SampleActivity.java

示例7: formatHash

import android.text.style.TypefaceSpan; //导入依赖的package包/类
public static Editable formatHash(@Nullable final String prefix, final String address, final int groupSize,
        final int lineSize, final char groupSeparator) {
    final SpannableStringBuilder builder = prefix != null ? new SpannableStringBuilder(prefix)
            : new SpannableStringBuilder();

    final int len = address.length();
    for (int i = 0; i < len; i += groupSize) {
        final int end = i + groupSize;
        final String part = address.substring(i, end < len ? end : len);

        builder.append(part);
        builder.setSpan(new TypefaceSpan("monospace"), builder.length() - part.length(), builder.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (end < len) {
            final boolean endOfLine = lineSize > 0 && end % lineSize == 0;
            builder.append(endOfLine ? '\n' : groupSeparator);
        }
    }

    return builder;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:22,代码来源:WalletUtils.java

示例8: handleEndTag

import android.text.style.TypefaceSpan; //导入依赖的package包/类
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class,
                new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}
 
开发者ID:elibo,项目名称:ScribaNotesApp,代码行数:24,代码来源:Html.java

示例9: initializeResources

import android.text.style.TypefaceSpan; //导入依赖的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);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:19,代码来源:PassphrasePromptActivity.java

示例10: setGroupTitle

import android.text.style.TypefaceSpan; //导入依赖的package包/类
/**
 * Set the title for the preference group.
 * @param resourceId The resource id of the text to use.
 * @param count The number of entries the preference group contains.
 */
public void setGroupTitle(int resourceId, int count) {
    SpannableStringBuilder spannable =
            new SpannableStringBuilder(getContext().getResources().getString(resourceId));
    String prefCount = String.format(Locale.getDefault(), " - %d", count);
    spannable.append(prefCount);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
                   0,
                   spannable.length() - prefCount.length(),
                   Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        spannable.setSpan(new TypefaceSpan("sans-serif-medium"),
                   0,
                   spannable.length() - prefCount.length(),
                   Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    int gray = getContext().getResources().getColor(R.color.expandable_group_dark_gray);
    spannable.setSpan(new ForegroundColorSpan(gray),
               spannable.length() - prefCount.length(),
               spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    setTitle(spannable);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:30,代码来源:ExpandablePreferenceGroup.java

示例11: formatHash

import android.text.style.TypefaceSpan; //导入依赖的package包/类
public static Editable formatHash(@Nullable final String prefix, @NonNull final String
        address, final int groupSize, final int lineSize, final char groupSeparator) {
    final SpannableStringBuilder builder = prefix != null ? new SpannableStringBuilder
            (prefix) : new SpannableStringBuilder();

    final int len = address.length();
    for (int i = 0;
         i < len;
         i += groupSize) {
        final int end = i + groupSize;
        final String part = address.substring(i, end < len ? end : len);

        builder.append(part);
        builder.setSpan(new TypefaceSpan("monospace"), builder.length() - part.length(),
                builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (end < len) {
            final boolean endOfLine = lineSize > 0 && end % lineSize == 0;
            builder.append(endOfLine ? '\n' : groupSeparator);
        }
    }

    return builder;
}
 
开发者ID:chaincloud-dot-com,项目名称:chaincloud-v,代码行数:24,代码来源:BitcoinUtil.java

示例12: formatHash

import android.text.style.TypefaceSpan; //导入依赖的package包/类
public static Editable formatHash(@Nullable final String prefix, final String address, final int groupSize, final int lineSize,
        final char groupSeparator)
{
    final SpannableStringBuilder builder = prefix != null ? new SpannableStringBuilder(prefix) : new SpannableStringBuilder();

    final int len = address.length();
    for (int i = 0; i < len; i += groupSize)
    {
        final int end = i + groupSize;
        final String part = address.substring(i, end < len ? end : len);

        builder.append(part);
        builder.setSpan(new TypefaceSpan("monospace"), builder.length() - part.length(), builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (end < len)
        {
            final boolean endOfLine = lineSize > 0 && end % lineSize == 0;
            builder.append(endOfLine ? '\n' : groupSeparator);
        }
    }

    return builder;
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:23,代码来源:WalletUtils.java

示例13: initializeResources

import android.text.style.TypefaceSpan; //导入依赖的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);
  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());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:17,代码来源:PassphrasePromptActivity.java

示例14: testInitializationDecodeWithStyl

import android.text.style.TypefaceSpan; //导入依赖的package包/类
public void testInitializationDecodeWithStyl() throws IOException, SubtitleDecoderException {
  byte[] initBytes = TestUtil.getByteArray(getInstrumentation(), INITIALIZATION);
  Tx3gDecoder decoder = new Tx3gDecoder(Collections.singletonList(initBytes));
  byte[] bytes = TestUtil.getByteArray(getInstrumentation(), SAMPLE_WITH_STYL);
  Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
  SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
  assertEquals("CC Test", text.toString());
  assertEquals(5, text.getSpans(0, text.length(), Object.class).length);
  StyleSpan styleSpan = findSpan(text, 0, text.length(), StyleSpan.class);
  assertEquals(Typeface.BOLD_ITALIC, styleSpan.getStyle());
  findSpan(text, 0, text.length(), UnderlineSpan.class);
  TypefaceSpan typefaceSpan = findSpan(text, 0, text.length(), TypefaceSpan.class);
  assertEquals(C.SERIF_NAME, typefaceSpan.getFamily());
  ForegroundColorSpan colorSpan = findSpan(text, 0, text.length(), ForegroundColorSpan.class);
  assertEquals(Color.RED, colorSpan.getForegroundColor());
  colorSpan = findSpan(text, 0, 6, ForegroundColorSpan.class);
  assertEquals(Color.GREEN, colorSpan.getForegroundColor());
  assertFractionalLinePosition(subtitle.getCues(0).get(0), 0.1f);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:20,代码来源:Tx3gDecoderTest.java

示例15: testInitializationDecodeWithTbox

import android.text.style.TypefaceSpan; //导入依赖的package包/类
public void testInitializationDecodeWithTbox() throws IOException, SubtitleDecoderException {
  byte[] initBytes = TestUtil.getByteArray(getInstrumentation(), INITIALIZATION);
  Tx3gDecoder decoder = new Tx3gDecoder(Collections.singletonList(initBytes));
  byte[] bytes = TestUtil.getByteArray(getInstrumentation(), SAMPLE_WITH_TBOX);
  Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
  SpannedString text = new SpannedString(subtitle.getCues(0).get(0).text);
  assertEquals("CC Test", text.toString());
  assertEquals(4, text.getSpans(0, text.length(), Object.class).length);
  StyleSpan styleSpan = findSpan(text, 0, text.length(), StyleSpan.class);
  assertEquals(Typeface.BOLD_ITALIC, styleSpan.getStyle());
  findSpan(text, 0, text.length(), UnderlineSpan.class);
  TypefaceSpan typefaceSpan = findSpan(text, 0, text.length(), TypefaceSpan.class);
  assertEquals(C.SERIF_NAME, typefaceSpan.getFamily());
  ForegroundColorSpan colorSpan = findSpan(text, 0, text.length(), ForegroundColorSpan.class);
  assertEquals(Color.RED, colorSpan.getForegroundColor());
  assertFractionalLinePosition(subtitle.getCues(0).get(0), 0.1875f);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:18,代码来源:Tx3gDecoderTest.java


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