當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。