Java 类android.graphics.Typeface 实例源码

项目:AOSP-Kayboard-7.1.2    文件:SuggestionStripLayoutHelper.java   
private static int getTextWidth(@Nullable final CharSequence text, final TextPaint paint) {
    if (TextUtils.isEmpty(text)) {
        return 0;
    }
    final int length = text.length();
    final float[] widths = new float[length];
    final int count;
    final Typeface savedTypeface = paint.getTypeface();
    try {
        paint.setTypeface(getTextTypeface(text));
        count = paint.getTextWidths(text, 0, length, widths);
    } finally {
        paint.setTypeface(savedTypeface);
    }
    int width = 0;
    for (int i = 0; i < count; i++) {
        width += Math.round(widths[i] + 0.5f);
    }
    return width;
}
项目:QuranKeyboard    文件:QuranKeyboardIME.java   
/**
 * Main initialization of the input method component.  Be sure to call
 * to super class.
 */
@Override public void onCreate() {
    super.onCreate();
    mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    mWordSeparators = getResources().getString(R.string.word_separators);
    mSuggestions = EMPTY_LIST;
    mQuranSuggestions = EMPTY_MLIST;
    mSavedPreSpaces = 0;

    try {
        mQuranSearch = new QuranSearch(this);
    } catch (IOException |SecurityException e) {
        mQuranSearch = null;
        Toast.makeText(this, "Quran Search disabled, File not found!", Toast.LENGTH_LONG).show();
        // TODO disable/gray the Moshaf/shift key & disable/grey Prefs
        if (DEBUG) e.printStackTrace();
    }

    if (mQuranSearch != null) {
        PreferenceManager.setDefaultValues(this, R.xml.ime_preferences, false);

        setUthmaniTypeFace(Typeface.createFromAsset(getAssets(), "UthmanicHafs.otf"));
    }
}
项目:snippety    文件:SnippetyUtil.java   
private static SnipettyAttr getDefaultAttr(Context context) {
    SnipettyAttr attr = new SnipettyAttr();

    Resources resources = context.getResources();
    attr.leadGap = resources.getDimensionPixelOffset(R.dimen.space_medium);
    attr.gapWidth = resources.getDimensionPixelOffset(R.dimen.space_xlarge);
    attr.textColor = ContextCompat.getColor(context, R.color.secondary_text);
    attr.titleTextSize = resources.getDimensionPixelOffset(R.dimen.text_xlarge);
    attr.subTitleTextSize = resources.getDimensionPixelOffset(R.dimen.text_medium);
    attr.titleTextColor = ContextCompat.getColor(context, R.color.primary_text);
    attr.subTitleTextColor = ContextCompat.getColor(context, R.color.primary_text);
    attr.titleTextFont = Typeface.createFromAsset(context.getAssets(),
            context.getString(R.string.font_roboto_bold));
    attr.subtitleTextFont = Typeface.createFromAsset(context.getAssets(),
            context.getString(R.string.font_roboto_medium));

    return attr;
}
项目:q-mail    文件:MessageHeader.java   
/**
 * Set up the additional headers text view with the supplied header data.
 *
 * @param additionalHeaders List of header entries. Each entry consists of a header
 *                          name and a header value. Header names may appear multiple
 *                          times.
 *                          <p/>
 *                          This method is always called from within the UI thread by
 *                          {@link #showAdditionalHeaders()}.
 */
private void populateAdditionalHeadersView(final List<HeaderEntry> additionalHeaders) {
    SpannableStringBuilder sb = new SpannableStringBuilder();
    boolean first = true;
    for (HeaderEntry additionalHeader : additionalHeaders) {
        if (!first) {
            sb.append("\n");
        } else {
            first = false;
        }
        StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
        SpannableString label = new SpannableString(additionalHeader.label + ": ");
        label.setSpan(boldSpan, 0, label.length(), 0);
        sb.append(label);
        sb.append(MimeUtility.unfoldAndDecode(additionalHeader.value));
    }
    mAdditionalHeadersView.setText(sb);
}
项目:FontProvider    文件:TypefaceCompat.java   
/**
 * Return Typeface.sSystemFontMap.
 *
 * @return Typeface.sSystemFontMap
 */
@SuppressWarnings("unchecked")
@Nullable
public static Map<String, Typeface> getSystemFontMap() {
    if (!available) {
        return null;
    }

    if (sSystemFontMap == null) {
        try {
            sSystemFontMap = (Map<String, Typeface>) sSystemFontMapField.get(null);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return null;
        }
    }

    return sSystemFontMap;
}
项目:Leanplum-Android-SDK    文件:BaseMessageDialog.java   
private RelativeLayout createTitleView(Context context) {
  RelativeLayout view = new RelativeLayout(context);
  view.setLayoutParams(new LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

  TextView title = new TextView(context);
  title.setPadding(0, SizeUtil.dp5, 0, SizeUtil.dp5);
  title.setGravity(Gravity.CENTER);
  title.setText(options.getTitle());
  title.setTextColor(options.getTitleColor());
  title.setTextSize(TypedValue.COMPLEX_UNIT_SP, SizeUtil.textSize0);
  title.setTypeface(null, Typeface.BOLD);
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
  layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
  title.setLayoutParams(layoutParams);

  view.addView(title, title.getLayoutParams());
  return view;
}
项目:StyleableToast    文件:StyleableToast.java   
private void makeTextView() {
    loadTextViewStyleAttributes();
    textView.setText(text);
    if (textColor != 0) {
        textView.setTextColor(textColor);
    }

    if (textSize > 0) {
        textView.setTextSize(isTextSizeFromStyle ? 0 : TypedValue.COMPLEX_UNIT_SP, textSize);
    }

    if (textBold && typeface == null) {
        textView.setTypeface(Typeface.create(context.getString(R.string.default_font), Typeface.BOLD));
    } else if (textBold) {
        textView.setTypeface(Typeface.create(typeface, Typeface.BOLD));
    } else if (typeface != null) {
        textView.setTypeface(typeface);
        //TODO THIS CHECK IS DEPRECATED AND WILL BE DELETED SOON
    } else if (fontId > 0) {
        textView.setTypeface(ResourcesCompat.getFont(context, fontId));
    }
}
项目:encdroidMC    文件:FontTypePreference.java   
/****************************************************************
 * getView
 *      the overroad getView method */
public View getView(int position, View convertView, ViewGroup parent) 
{
    // get the view that would normally be returned
    View v = super.getView(position, convertView, parent);
    final TextView tv = (TextView) v;

    final String option = tv.getText().toString();          
    if (option.equals("Serif"))
        tv.setTypeface(Typeface.SERIF);
    else if (option.equals("Sans Serif"))
        tv.setTypeface(Typeface.SANS_SERIF);
    else if (option.equals("Monospace"))
        tv.setTypeface(Typeface.MONOSPACE);

    // general options
    tv.setTextColor(Color.BLACK);
    tv.setPadding(10, 3, 3, 3);

    return v;   
}
项目:Raffler-Android    文件:ATextView.java   
public void setTextStyle(int style) {
        if(isInEditMode())
            return;

        String font;
        switch (style) {
            case Typeface.BOLD:
                font = Stylish.FONT_BOLD;
                break;
            case Typeface.ITALIC:
                font = Stylish.FONT_ITALIC;
                break;
            case Typeface.NORMAL:
                font = Stylish.FONT_REGULAR;
                break;
            default:
                font = Stylish.FONT_REGULAR;
        }

        try {

            setTypeface(Stylish.getInstance().getTypeface(getContext(), font, getTypeface()));
        } catch (Exception e) {
//            e.printStackTrace();
        }
    }
项目:ButterToast    文件:ButterToast.java   
public static Toast custom(@NonNull Context context, CharSequence text, @Nullable Drawable icon,
                           @ColorInt int backgroundColor, int duration, @DrawableRes int resid,
                           @Nullable Typeface tp, float cornerRadius,
                           @ColorInt int textColor, float textSize) {
    Toast toast = new Toast(context);

    View layout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.toast_layout, null);
    LinearLayout ll = (LinearLayout) layout.findViewById(R.id.base_layout);
    ll.setBackgroundResource(resid);
    GradientDrawable gd = (GradientDrawable) ll.getBackground().getCurrent();
    gd.setColor(backgroundColor);
    gd.setCornerRadius(cornerRadius);
    TextView tv_message = (TextView) layout.findViewById(R.id.toast_text);
    tv_message.setTextSize(textSize);
    tv_message.setTypeface(tp == null ? DEFAULT_TYPEFACE : tp);
    tv_message.setTextColor(textColor);
    ImageView iv_toast_image = (ImageView) layout.findViewById(R.id.toast_image);
    if (icon != null) {
        iv_toast_image.setImageDrawable(icon);
    }
    tv_message.setText(text);
    toast.setView(layout);
    toast.setDuration(duration);
    return toast;
}
项目:Hello-KUET    文件:home.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.homepage);

    hellokuet = (TextView) findViewById(R.id.hellokuet);
    Email = (EditText) findViewById(R.id.input_email);
    Password = (EditText) findViewById(R.id.input_password);
    login = (Button) findViewById(R.id.btn_login);

    ttf1 = Typeface.createFromAsset(getAssets(),"fonts/trench100free.ttf");
    hellokuet.setTypeface(ttf1);


    login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Intent ints = new Intent(home.this , MainActivity.class);
           //startActivity(ints);
        }
    });



}
项目:OneTwo    文件:TouchDisplayView.java   
private void initialisePaint() {

        // Calculate radiuses i n px from dp based on screen density
        float density = getResources().getDisplayMetrics().density;
        mCircleRadius = CIRCLE_RADIUS_DP * density;
        //we want to know the screen width to make the white text remain in the screen
        Configuration configuration = getContext().getResources().getConfiguration();
        mScreenWidth = configuration.smallestScreenWidthDp * (int) density ;
        //mCircleHistoricalRadius = CIRCLE_HISTORICAL_RADIUS_DP * density;

        // Setup text paint for circle label
        mTextPaint.setTextSize(30f*density);
        mStrokePaint.setTextSize(30f*density);
        mTextPaint.setColor(Color.WHITE);
        mStrokePaint.setColor(Color.WHITE);
        mTransStrokePaint.setColor(Color.WHITE);
        mTextPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
        mStrokePaint.setStyle(Paint.Style.STROKE);
        mStrokePaint.setStrokeWidth(6f* density);
        mTransStrokePaint.setStyle(Paint.Style.STROKE);
        mTransStrokePaint.setStrokeWidth(6f* density);

    }
项目:microMathematics    文件:SVGAndroidRenderer.java   
private Typeface checkGenericFont(String fontName, Integer fontWeight,
        FontStyle fontStyle) {
    Typeface font = null;
    int typefaceStyle;

    boolean italic = (fontStyle == Style.FontStyle.Italic);
    typefaceStyle = (fontWeight > 500) ? (italic ? Typeface.BOLD_ITALIC
            : Typeface.BOLD) : (italic ? Typeface.ITALIC : Typeface.NORMAL);

    if (fontName.equals("serif")) {
        font = Typeface.create(Typeface.SERIF, typefaceStyle);
    } else if (fontName.equals("sans-serif")) {
        font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
    } else if (fontName.equals("monospace")) {
        font = Typeface.create(Typeface.MONOSPACE, typefaceStyle);
    } else if (fontName.equals("cursive")) {
        font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
    } else if (fontName.equals("fantasy")) {
        font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
    }
    return font;
}
项目:MyEyepetizer    文件:VideoItemBinder.java   
@Override
protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull final VideoItem item) {
    if (item.data.cover.homePageCover != null) {
        Glide.with(mActivity).load(item.data.cover.homePageCover).into(holder.imageButton);
    } else {
        Glide.with(mActivity).load(item.data.cover.detailCover).into(holder.imageButton);
    }
    holder.imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mActivity, MovieDetailActivity.class);
            Bundle bundle = new Bundle();
            bundle.putParcelable("DATA", item.data);
            intent.putExtras(bundle);
            mActivity.startActivity(intent);
        }
    });

    holder.title.setText(item.data.title);
    holder.title.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.DB1FontPath)));
    holder.info.setText("#" + item.data.category + "  /  " + TranslateDuration.translateSeconds(item.data.duration));
    holder.info.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.LFontPath)));
}
项目:anitrend-app    文件:DialogManager.java   
public void createDialogSelection(String title , int selection, MaterialDialog.ListCallbackSingleChoice callbackSingleChoice, MaterialDialog.SingleButtonCallback positive, int index){
    new MaterialDialog.Builder(mContext)
            .title(title)
            .items(selection)
            .typeface(Typeface.SANS_SERIF,Typeface.SANS_SERIF)
            .iconRes(app_prefs.isLightTheme()?R.drawable.ic_view_list_black_24dp:R.drawable.ic_view_list_white_24dp)
            .buttonRippleColorRes(R.color.colorAccent)
            .positiveColorRes(R.color.colorStateBlue)
            .negativeColorRes(R.color.colorStateOrange)
            .theme(app_prefs.isLightTheme()?Theme.LIGHT:Theme.DARK)
            .itemsCallbackSingleChoice(index, callbackSingleChoice)
            .positiveText(R.string.Apply)
            .neutralText(R.string.Cancel)
            .onPositive(positive)
            .onNeutral(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    dialog.dismiss();
                }
            })
            .show();
}
项目:buildAPKsApps    文件:AboutApp.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aboutapp);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    tvAbt = (TextView) findViewById(R.id.tvAboutHdr);
    tvVers = (TextView) findViewById(R.id.tvVersion);
    tvCopy = (TextView) findViewById(R.id.tvCopyright);
    tvCon = (TextView) findViewById(R.id.tvContact);

    tvAbt.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/highschool.ttf"));
    tvVers.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/highschool.ttf"));
    tvCopy.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/highschool.ttf"));
    tvCon.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/highschool.ttf"));
}
项目:CommonsLab    文件:MainActivity.java   
private void setupCollapsingImage() {
    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);

    //Fade out CollapsingToolbarLayout title ...from white to transparent
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    Typeface type = Typeface.createFromAsset(getAssets(), "fonts/open_sans/OpenSans-Light.ttf");
    collapsingToolbarLayout.setExpandedTitleTypeface(type);//fonts
    collapsingToolbarLayout.setCollapsedTitleTypeface(type);

    collapsingToolbarLayout.setTitle(getString(R.string.pod));
    collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.white_opacity));
    collapsingToolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.white_opacity_king));

    //Set Picture of the day to collapsing ImageView
    collapsingImageView = (ImageView) findViewById(R.id.collapsing_ImageView);

    pictureOfTheDayList = storage.retrieveRSS_Feed(MediaType.PICTURE);
    if (pictureOfTheDayList != null &&
            pictureOfTheDayList.size() > 0 &&
            pictureOfTheDayList.get(0) != null &&
            pictureOfTheDayList.get(0).getMediaLink() != null)
        Glide.with(this)
                .load(pictureOfTheDayList.get(0).getMediaLink())
                .centerCrop()
                .into(collapsingImageView);
}
项目:ywApplication    文件:EditPage.java   
private LinearLayout getBodyBottom() {
    LinearLayout llBottom = new LinearLayout(getContext());
    llBottom.setLayoutParams(new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    LinearLayout line = getAtLine(platforms.get(0).getName());
    if (line != null) {
        llBottom.addView(line);
    }

    // Words counter
    tvCounter = new TextView(getContext());
    tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
    tvCounter.setTextColor(0xffcfcfcf);
    tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
    LayoutParams lpCounter = new LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpCounter.gravity = Gravity.CENTER_VERTICAL;
    tvCounter.setLayoutParams(lpCounter);
    llBottom.addView(tvCounter);

    return llBottom;
}
项目:GitHub    文件:CalligraphyTypefaceSpan.java   
public CalligraphyTypefaceSpan(final Typeface typeface) {
    if (typeface == null) {
        throw new IllegalArgumentException("typeface is null");
    }

    this.typeface = typeface;
}
项目:wallpaperboard    文件:TypefaceHelper.java   
@Nullable
public static Typeface getBold(@NonNull Context context) {
    try {
        if (!mTypefaces.containsKey(BOLD) || mTypefaces.get(BOLD).get() == null) {
            Typeface typeface = Typeface.createFromAsset(
                    context.getAssets(), "fonts/Font-Bold.ttf");
            mTypefaces.put(BOLD, new WeakReference<>(typeface));
        }
        return mTypefaces.get(BOLD).get();
    } catch (Exception e) {
        return null;
    }
}
项目:weex-3d-map    文件:SearchBookContentsListItem.java   
public void set(SearchBookContentsResult result) {
  pageNumberView.setText(result.getPageNumber());
  String snippet = result.getSnippet();
  if (snippet.isEmpty()) {
    snippetView.setText("");
  } else {
    if (result.getValidSnippet()) {
      String lowerQuery = SearchBookContentsResult.getQuery().toLowerCase(Locale.getDefault());
      String lowerSnippet = snippet.toLowerCase(Locale.getDefault());
      Spannable styledSnippet = new SpannableString(snippet);
      StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
      int queryLength = lowerQuery.length();
      int offset = 0;
      while (true) {
        int pos = lowerSnippet.indexOf(lowerQuery, offset);
        if (pos < 0) {
          break;
        }
        styledSnippet.setSpan(boldSpan, pos, pos + queryLength, 0);
        offset = pos + queryLength;
      }
      snippetView.setText(styledSnippet);
    } else {
      // This may be an error message, so don't try to bold the query terms within it
      snippetView.setText(snippet);
    }
  }
}
项目:QuickActionView    文件:QuickActionView.java   
private Config(Context context, Typeface typeface, int textSize, int textPadding) {
    mTypeface = typeface;
    mTextSize = textSize;
    mTextPaddingTop = textPadding;
    mTextPaddingBottom = textPadding;
    mTextPaddingLeft = textPadding;
    mTextPaddingRight = textPadding;
    mDefaultConfig = new Action.Config(context);
}
项目:ucar-weex-core    文件:TypefaceUtil.java   
public static Typeface getOrCreateTypeface(String family, int style) {
  FontDO fontDo = sCacheMap.get(family);
  if (fontDo != null && fontDo.getTypeface() != null) {
    return fontDo.getTypeface();
  }

  return Typeface.create(family, style);
}
项目:CoachMarks    文件:DefaultTypeFaceProvider.java   
@Override
@Nullable
public Typeface getTypeFaceFromAssets(final String fontFilePath) {
    try {
        return Typeface.createFromAsset(mContext.getAssets(), fontFilePath);
    } catch (RuntimeException e) {
        Log.e(DefaultTypeFaceProvider.class.getName(), e.getMessage());
    }
    return null;
}
项目:MultiFontView-Android    文件:FontLoader.java   
public static Typeface getTypeface(Context context, String fontname) {
    Typeface typeface = fontMapCache.get(fontname);

    if (typeface == null) {
        try {
            typeface = Typeface.createFromAsset(context.getAssets(), "fonts/" + fontname);
        } catch (Exception e) {
            return null;
        }

        fontMapCache.put(fontname, typeface);
    }

    return typeface;
}
项目:Android-Wear-Projects    文件:PacktWatchFace.java   
private Paint createPaint(final boolean bold, final int fontSize) {
    final Typeface typeface = (bold) ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT;

    return new Paint()
    {{
        setARGB(255, 255, 255, 255);
        setTextSize(fontSize);
        setTypeface(typeface);
        setAntiAlias(true);
    }};
}
项目:today-menu-android    文件:RestaurantActivity.java   
@SuppressWarnings("ConstantConditions")
private void initToolbar() {
    Typeface expandedFont = Typeface.createFromAsset(getAssets(), "fonts/CrimsonText-Bold.ttf");
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle(mRestaurant.mName);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mCollapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedTitle);
    mCollapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedTitle);
    mCollapsingToolbarLayout.setCollapsedTitleTypeface(expandedFont);
    mCollapsingToolbarLayout.setExpandedTitleTypeface(expandedFont);
}
项目:FontProvider    文件:TypefaceCompatApi26.java   
@Nullable
public static Typeface createFromFamiliesWithDefault(Object families, int weight, int italic) {
    if (!available) {
        return null;
    }

    try {
        return (Typeface) createFromFamiliesWithDefaultMethod.invoke(null, families,
                weight, italic);
    } catch (IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
        return null;
    }
}
项目:HotFixDemo    文件:MainActivity.java   
public void show_info(View view) {
    // add more Build Info
    final StringBuilder sb = new StringBuilder();
    Tinker tinker = Tinker.with(getApplicationContext());
    if (tinker.isTinkerLoaded()) {
        sb.append(String.format("[patch is loaded] \n"));
        sb.append(String.format("[buildConfig TINKER_ID] %s \n", BuildInfo.TINKER_ID));
        sb.append(String.format("[buildConfig BASE_TINKER_ID] %s \n", BaseBuildInfo.BASE_TINKER_ID));

        sb.append(String.format("[buildConfig MESSSAGE] %s \n", BuildInfo.MESSAGE));
        sb.append(String.format("[TINKER_ID] %s \n", tinker.getTinkerLoadResultIfPresent().getPackageConfigByName(ShareConstants.TINKER_ID)));
        sb.append(String.format("[packageConfig patchMessage] %s \n", tinker.getTinkerLoadResultIfPresent().getPackageConfigByName("patchMessage")));
        sb.append(String.format("[TINKER_ID Rom Space] %d k \n", tinker.getTinkerRomSpace()));

    } else {
        sb.append(String.format("[patch is not loaded] \n"));
        sb.append(String.format("[buildConfig TINKER_ID] %s \n", BuildInfo.TINKER_ID));
        sb.append(String.format("[buildConfig BASE_TINKER_ID] %s \n", BaseBuildInfo.BASE_TINKER_ID));

        sb.append(String.format("[buildConfig MESSSAGE] %s \n", BuildInfo.MESSAGE));
        sb.append(String.format("[TINKER_ID] %s \n", ShareTinkerInternals.getManifestTinkerID(getApplicationContext())));
    }
    sb.append(String.format("[BaseBuildInfo Message] %s \n", BaseBuildInfo.TEST_MESSAGE));

    final TextView v = new TextView(this);
    v.setText(sb);
    v.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    v.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
    v.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    v.setTextColor(0xFF000000);
    v.setTypeface(Typeface.MONOSPACE);
    final int padding = 16;
    v.setPadding(padding, padding, padding, padding);

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(true);
    builder.setView(v);
    final AlertDialog alert = builder.create();
    alert.show();
}
项目:android-permission-checker-app    文件:TypeFaceTextView.java   
private void init(AttributeSet attrs) {
  if (attrs != null) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TypeFaceTextView);
    String fontName = a.getString(R.styleable.TypeFaceTextView_fontName);
    if (fontName != null) {
      Typeface myTypeface = inflatedFonts.get(fontName);
      if (myTypeface == null) {
        myTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/" + fontName);
        inflatedFonts.put(fontName, myTypeface);
      }
      setTypeface(myTypeface);
    }
    a.recycle();
  }
}
项目:mapbox-navigation-android    文件:TimeUtils.java   
public static SpannableStringBuilder formatTimeRemaining(double routeDuration) {
  long seconds = (long) routeDuration;

  if (seconds < 0) {
    throw new IllegalArgumentException("Duration must be greater than zero.");
  }

  long days = TimeUnit.SECONDS.toDays(seconds);
  seconds -= TimeUnit.DAYS.toSeconds(days);
  long hours = TimeUnit.SECONDS.toHours(seconds);
  seconds -= TimeUnit.HOURS.toSeconds(hours);
  long minutes = TimeUnit.SECONDS.toMinutes(seconds);
  seconds -= TimeUnit.MINUTES.toSeconds(minutes);

  if (seconds >= 30) {
    minutes = minutes + 1;
  }

  List<SpanItem> spanItems = new ArrayList<>();
  if (days != 0) {
    String dayFormat = days > 1 ? DAYS : DAY;
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(days)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), dayFormat));
  }
  if (hours != 0) {
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(hours)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), HOUR));
  }
  if (minutes != 0) {
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(minutes)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), MINUTE));
  }
  if (days == 0 && hours == 0 && minutes == 0) {
    spanItems.add(new SpanItem(new StyleSpan(Typeface.BOLD), String.valueOf(1)));
    spanItems.add(new SpanItem(new RelativeSizeSpan(1f), MINUTE));
  }

  return SpanUtils.combineSpans(spanItems);
}
项目:ElasticViews    文件:ElasticCheckButton.java   
private void setTypeArray(TypedArray typedArray){
    GradientDrawable bgShape = (GradientDrawable)view.getBackground();

    round = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_round, round);
    bgShape.setCornerRadius(round);

    color = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_backgroundColor, color);
    bgShape.setColor(color);

    scale = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_scale, scale);

    duration = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_duration, duration);

    labelText = typedArray.getString(R.styleable.ElasticCheckButton_checkbutton_labelText);
    view.setText(labelText);

    labelColor = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelColor, labelColor);
    view.setTextColor(labelColor);

    labelSize = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelSize, labelSize);
    view.setTextSize(labelSize);

    labelStyle = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelStyle, labelStyle);

    if(labelStyle == 0)
        view.setTypeface(null, Typeface.NORMAL);
    else if(labelStyle == 1)
        view.setTypeface(null, Typeface.BOLD);
    else if(labelStyle == 2)
        view.setTypeface(null, Typeface.ITALIC);

    alpha = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_alpha, alpha);

    checked = typedArray.getBoolean(R.styleable.ElasticCheckButton_checkbutton_ischecked, checked);
    if(checked) view.setAlpha(alpha);
}
项目:AssistantBySDK    文件:MonthView.java   
/**
     * Sets up the text and style properties for painting. Override this if you
     * want to use a different paint.
     */
    protected void initView() {
        mMonthTitlePaint = new Paint();
        mMonthTitlePaint.setFakeBoldText(true);
        mMonthTitlePaint.setAntiAlias(true);
        mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE);
        mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD));
        mMonthTitlePaint.setColor(mDayTextColor);
        mMonthTitlePaint.setTextAlign(Align.CENTER);
        mMonthTitlePaint.setStyle(Style.FILL);

        mSelectedCirclePaint = new Paint();
        mSelectedCirclePaint.setFakeBoldText(true);
        mSelectedCirclePaint.setAntiAlias(true);
        mSelectedCirclePaint.setColor(mTodayNumberColor);
        mSelectedCirclePaint.setTextAlign(Align.CENTER);
        mSelectedCirclePaint.setStyle(Style.FILL);
        mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);

        mMonthDayLabelPaint = new Paint();
        mMonthDayLabelPaint.setAntiAlias(true);
        mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE);
        mMonthDayLabelPaint.setColor(mMonthDayTextColor);
//        mMonthDayLabelPaint.setTypeface(TypefaceHelper.get(getContext(),"Roboto-Medium"));
        mMonthDayLabelPaint.setStyle(Style.FILL);
        mMonthDayLabelPaint.setTextAlign(Align.CENTER);
        mMonthDayLabelPaint.setFakeBoldText(true);

        mMonthNumPaint = new Paint();
        mMonthNumPaint.setAntiAlias(true);
        mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE);
        mMonthNumPaint.setStyle(Style.FILL);
        mMonthNumPaint.setTextAlign(Align.CENTER);
        mMonthNumPaint.setFakeBoldText(false);
    }
项目:GitHub    文件:TerminalTextViewOverlay.java   
public TerminalTextViewOverlay(Context context, TerminalView terminalView) {
    super(context);

    this.terminalView = terminalView;
    clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);

    setTextColor(Color.TRANSPARENT);
    setTypeface(Typeface.MONOSPACE);
    setTextIsSelectable(true);
    setCustomSelectionActionModeCallback(new TextSelectionActionModeCallback());
}
项目:Alerter    文件:ExampleActivity.java   
private void showAlertWithCustomFont() {
    Alerter.create(ExampleActivity.this)
            .setTitle("Alert Title")
            .setTitleAppearance(R.style.AlertTextAppearance_Title)
            .setTitleTypeface(Typeface.createFromAsset(getAssets(), "Pacifico-Regular.ttf"))
            .setText("Alert text...")
            .setTextAppearance(R.style.AlertTextAppearance_Text)
            .setTextTypeface(Typeface.createFromAsset(getAssets(), "ScopeOne-Regular.ttf"))
            .show();
}
项目:Channelize    文件:TimerFragment.java   
private void setScreenElements() {
    mCircularProgressBar = (HoloCircularProgressBar) view.findViewById(R.id.circular_progressBar);
    mTextViewTimer = (TextView)view.findViewById(R.id.text_timer);
    mButtonStart = (Button)view.findViewById(R.id.button_start);
    mButtonPause = (Button)view.findViewById(R.id.button_pause);
    mButtonResume = (Button)view.findViewById(R.id.button_resume);
    mButtonStop = (Button)view.findViewById(R.id.button_stop);

    if (mTextViewTimer != null) {
        mTextViewTimer.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Light.ttf"));
    }

    updateTimerLabel((int) TimeUnit.MINUTES.toSeconds(timerDuration));
}
项目:nativehtml    文件:AndroidCss.java   
static int getTextStyle(CssStyleDeclaration style) {
  int flags = 0;
  if (style.get(CssProperty.FONT_WEIGHT, CssUnit.NUMBER) > 600) {
    flags |= Typeface.BOLD;
  }
  if (style.getEnum(CssProperty.FONT_STYLE) == CssEnum.ITALIC) {
    flags |= Typeface.ITALIC;
  }
  return flags;
}
项目:BookReader-master    文件:EasyRVHolder.java   
@Override
public EasyRVHolder setTypeface(int viewId, Typeface typeface) {
    TextView view = getView(viewId);
    view.setTypeface(typeface);
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}
项目:browser    文件:CCPTabView.java   
/**
 *
 */
private void init() {

    int dip2px = DensityUtil.dip2px(2.0F);

    padding = getResources().getDimensionPixelSize(R.dimen.SmallestPadding);
    TextView description = new TextView(getContext());
    description.setSingleLine();
    description.setEllipsize(TextUtils.TruncateAt.END);
    description.setTextColor(getResources().getColor(R.color.ccp_green));
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX , getResources().getDimensionPixelSize(R.dimen.HintTextSize) + dip2px);
    description.setText(R.string.tab_view_name);
    description.setTypeface(null, Typeface.NORMAL);
    addView(mTabDescription = description);

    ImageView descriptionImage = new ImageView(getContext());
    descriptionImage.setImageResource(R.drawable.unread_dot);
    descriptionImage.setVisibility(View.INVISIBLE);
    addView(mTabImage = descriptionImage);

    TextView tips = new TextView(getContext());
    tips.setTextColor(getResources().getColor(android.R.color.white));
    tips.setTextSize(0, getResources().getDimensionPixelSize(R.dimen.SmallestTextSize));
    tips.setBackgroundResource(R.drawable.to_read_tips_onbackbtn);
    tips.setGravity(Gravity.CENTER);
    tips.setVisibility(View.INVISIBLE);

    addView(mTabUnreadTips = tips);

    setBackgroundResource(R.drawable.tab_item_bg);

}
项目:GitHub    文件:HalfPieChartActivity.java   
private SpannableString generateCenterSpannableText() {

        SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
        s.setSpan(new RelativeSizeSpan(1.7f), 0, 14, 0);
        s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
        s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
        s.setSpan(new RelativeSizeSpan(.8f), 14, s.length() - 15, 0);
        s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
        s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
        return s;
    }