Example usage for android.graphics Typeface NORMAL

List of usage examples for android.graphics Typeface NORMAL

Introduction

In this page you can find the example usage for android.graphics Typeface NORMAL.

Prototype

int NORMAL

To view the source code for android.graphics Typeface NORMAL.

Click Source Link

Usage

From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.SimpleMonthView.java

/**
 * Sets up the text and style properties for painting. Override this if you want to use a different paint.
 *///from   w  w w . j a  v a  2  s  .com
protected void initView() {
    mMonthTitlePaint = new Paint();
    mMonthTitlePaint.setFakeBoldText(true);
    mMonthTitlePaint.setAntiAlias(true);
    mMonthTitlePaint.setTextSize(sMonthLabelTextSize);
    mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD));
    mMonthTitlePaint.setColor(mDayTextColor);
    mMonthTitlePaint.setTextAlign(Align.CENTER);
    mMonthTitlePaint.setStyle(Style.FILL);

    mMonthTitleBGPaint = new Paint();
    mMonthTitleBGPaint.setFakeBoldText(true);
    mMonthTitleBGPaint.setAntiAlias(true);
    mMonthTitleBGPaint.setColor(mMonthTitleBGColor);
    mMonthTitleBGPaint.setTextAlign(Align.CENTER);
    mMonthTitleBGPaint.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(sMonthDayLabelTextSize);
    mMonthDayLabelPaint.setColor(mDayTextColor);
    mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL));
    mMonthDayLabelPaint.setStyle(Style.FILL);
    mMonthDayLabelPaint.setTextAlign(Align.CENTER);
    mMonthDayLabelPaint.setFakeBoldText(true);

    mMonthNumPaint = new Paint();
    mMonthNumPaint.setAntiAlias(true);
    mMonthNumPaint.setTextSize(sMiniDayNumberTextSize);
    mMonthNumPaint.setStyle(Style.FILL);
    mMonthNumPaint.setTextAlign(Align.CENTER);
    mMonthNumPaint.setFakeBoldText(false);
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static int toTypefaceStyle(final String fontWeight, final String fontStyle) {
    int style = Typeface.NORMAL;

    if (fontWeight != null) {
        if (fontWeight.equals("bold")) {
            if (fontStyle != null && fontStyle.equals("italic")) {
                style = Typeface.BOLD_ITALIC;
            } else {
                style = Typeface.BOLD;/*from w w w  .  ja v  a  2  s.c  om*/
            }
        } else if (fontStyle != null && fontStyle.equals("italic")) {
            style = Typeface.ITALIC;
        }
    } else if (fontStyle != null && fontStyle.equals("italic")) {
        style = Typeface.ITALIC;
    }
    return style;
}

From source file:com.layer.messenger.makemoji.MakeMojiAtlasComposer.java

private void parseStyle(Context context, AttributeSet attrs, int defStyle) {
    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs,
            com.layer.atlas.R.styleable.AtlasMessageComposer, com.layer.atlas.R.attr.AtlasMessageComposer,
            defStyle);// w  w w . ja v a  2s .co m
    mEnabled = ta.getBoolean(com.layer.atlas.R.styleable.AtlasMessageComposer_android_enabled, true);
    this.mTextColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextColor,
            context.getResources().getColor(com.layer.atlas.R.color.atlas_text_black));
    this.mTextSize = ta.getDimensionPixelSize(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextSize,
            context.getResources().getDimensionPixelSize(com.layer.atlas.R.dimen.atlas_text_size_input));
    this.mTextStyle = ta.getInt(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextStyle,
            Typeface.NORMAL);
    String typeFaceName = ta.getString(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextTypeface);
    this.mTypeFace = typeFaceName != null ? Typeface.create(typeFaceName, mTextStyle) : null;
    this.mUnderlineColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputUnderlineColor,
            context.getResources().getColor(com.layer.atlas.R.color.atlas_color_primary_blue));
    this.mCursorColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputCursorColor,
            context.getResources().getColor(com.layer.atlas.R.color.atlas_color_primary_blue));
    this.mAttachmentSendersBackground = ta
            .getDrawable(com.layer.atlas.R.styleable.AtlasMessageComposer_attachmentSendersBackground);
    ta.recycle();
}

From source file:android.support.design.widget.CustomCollapsingTextHelper.java

private Typeface readFontFamilyTypeface(int resId) {
    final TypedArray a = mView.getContext().obtainStyledAttributes(resId,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ? new int[] { android.R.attr.fontFamily }
                    : new int[0]);
    try {//from w  w w .j  ava 2s.  co m
        final String family = a.getString(0);
        if (family != null) {
            return Typeface.create(family, Typeface.NORMAL);
        }
    } catch (Exception e) {
        throw new RuntimeException("Unable to read font family typeface: " + resId);
    } finally {
        a.recycle();
    }
    return null;
}

From source file:android.support.design.widget.SubtitleCollapsingTextHelper.java

private Typeface readFontFamilyTypeface(int resId) {
    final TypedArray a = mView.getContext().obtainStyledAttributes(resId,
            android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN
                    ? new int[] { android.R.attr.fontFamily }
                    : new int[0]);
    try {/*  ww w.  ja v a 2 s  .  c o m*/
        final String family = a.getString(0);
        if (family != null) {
            return Typeface.create(family, Typeface.NORMAL);
        }
    } catch (Exception e) {
        throw new RuntimeException("Unable to read font family typeface: " + resId);
    } finally {
        a.recycle();
    }
    return null;
}

From source file:com.appsimobile.appsii.module.appsiagenda.MonthView.java

/**
 * Sets up the text and style properties for painting. Override this if you
 * want to use a different paint.//w  w  w  .  j  a  v  a2s  .c  om
 */
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(mMonthTitleColor);
    mMonthTitlePaint.setTextAlign(Align.CENTER);
    mMonthTitlePaint.setStyle(Style.FILL);

    mMonthTitleBGPaint = new Paint();
    mMonthTitleBGPaint.setFakeBoldText(true);
    mMonthTitleBGPaint.setAntiAlias(true);
    mMonthTitleBGPaint.setColor(mMonthTitleBGColor);
    mMonthTitleBGPaint.setTextAlign(Align.CENTER);
    mMonthTitleBGPaint.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);

    mEventDayCirclePaint = new Paint();
    mEventDayCirclePaint.setAntiAlias(true);
    mEventDayCirclePaint.setColor(mDayTextColor);
    mEventDayCirclePaint.setStyle(Style.STROKE);

    mMonthDayLabelPaint = new Paint();
    mMonthDayLabelPaint.setAntiAlias(true);
    mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE);
    mMonthDayLabelPaint.setColor(mDayTextColor);
    mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL));
    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);
}

From source file:opt.android.datetimepicker.date.MonthView.java

/**
 * Sets up the text and style properties for painting. Override this if you
 * want to use a different paint./*from w  w w . j a v a 2s .  c  o  m*/
 */
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(mMonthTitleColor);
    mMonthTitlePaint.setTextAlign(Align.CENTER);
    mMonthTitlePaint.setStyle(Style.FILL);

    //        mMonthTitleBGPaint = new Paint();
    //        mMonthTitleBGPaint.setFakeBoldText(true);
    //        mMonthTitleBGPaint.setAntiAlias(true);
    //        mMonthTitleBGPaint.setColor(mMonthTitleBGColor);
    //        mMonthTitleBGPaint.setTextAlign(Align.CENTER);
    //        mMonthTitleBGPaint.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(mDayTextColor);
    mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL));
    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);
}

From source file:utils.widget.vpi_lib.TabPageIndicator_Custom.java

@Override
public void setCurrentItem(final int item) {

    // final RippleView rippleView = (RippleView) mTabLayout
    // .findViewById(R.id.ripTabItem);
    // rippleView.setRippleColor(R.color.rippelColorOrange);
    // rippleView
    // .setOnRippleCompleteListener(new
    // RippleView.OnRippleCompleteListener() {
    ////from w  w w .j  a v a2s  .  c  om
    // @Override
    // public void onComplete(RippleView rippleView) {
    if (mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    mSelectedTabIndex = item;
    mViewPager.setCurrentItem(item);

    final int tabCount = mTabLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        final View child = mTabLayout.getChildAt(i);
        final boolean isSelected = (i == item);
        child.setSelected(isSelected);

        // TODO - Trigger (Arrow) Setting
        // Toast.makeText(getContext(),
        // "Selected ID :"+item,
        // Toast.LENGTH_SHORT).show();
        // ImageView img = (ImageView)
        // child.findViewById(R.id.img_trigger);
        TextView txtTitle = (TextView) child.findViewById(R.id.vpi_custom_txt_Title);
        TextView txtBottom = (TextView) child.findViewById(R.id.vpi_custom_txt_btm);

        if (isSelected) {
            animateToTab(item);
            txtBottom.setBackgroundColor(getResources().getColor(R.color.vpi_focus));
            txtBottom.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 8));
            txtTitle.setTextColor(getResources().getColor(R.color.vpi_focus));
            txtTitle.setTypeface(null, Typeface.BOLD);
            // img.setVisibility(View.VISIBLE);
        } else {
            txtBottom.setBackgroundColor(getResources().getColor(R.color.vpi_non_focus));
            txtBottom.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1));
            txtTitle.setTextColor(getResources().getColor(R.color.vpi_non_focus));
            txtTitle.setTypeface(null, Typeface.NORMAL);
            // img.setVisibility(View.INVISIBLE);
        }
    }
    // }
    //
    // });

}

From source file:com.github.irshulx.Components.InputExtensions.java

private void addEditableStyling(TextView editText) {
    editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL));
    editText.setFocusableInTouchMode(true);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE);
    editText.setTextColor(Color.parseColor(this.DEFAULT_TEXT_COLOR));
    editText.setPadding(0, 30, 0, 30);/* ww w .  ja v  a2 s .  c  o m*/
}

From source file:org.appspot.apprtc.util.ThumbnailsCacheManager.java

public static void LoadImage(final String url, LoadImageCallback callback, final Resources resources,
        final String displayname, final boolean rounded, boolean fromCache) {
    final LoadImageCallback mCallback = callback;
    final Handler uiHandler = new Handler();
    final int FG_COLOR = 0xFFFAFAFA;
    final String name = displayname;

    if (fromCache) {
        Bitmap bitmap = ThumbnailsCacheManager.getBitmapFromDiskCache(url);

        if (bitmap != null) {
            if (rounded) {
                RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory.create(resources, bitmap);
                roundedBitmap.setCircular(true);
                mCallback.onImageLoaded(roundedBitmap.getBitmap());
            } else {
                mCallback.onImageLoaded(bitmap);
            }//from   w w  w  .  j  av  a 2  s  .  c  o m
            return;
        }
    }

    AsyncHttpURLConnection httpConnection = new AsyncHttpURLConnection("GET", url, "",
            new AsyncHttpURLConnection.AsyncHttpEvents() {
                @Override
                public void onHttpError(String errorMessage) {
                    Log.d("LoadImage", errorMessage);
                }

                @Override
                public void onHttpComplete(String response) {
                    int size = 256;
                    Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
                    Canvas canvas = new Canvas(bitmap);
                    final String trimmedName = name == null ? "" : name.trim();
                    drawTile(canvas, trimmedName, 0, 0, size, size);
                    ThumbnailsCacheManager.addBitmapToCache(url, bitmap);
                    onHttpComplete(bitmap);
                }

                @Override
                public void onHttpComplete(final Bitmap response) {
                    if (mCallback != null) {
                        uiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                if (rounded) {
                                    RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory
                                            .create(resources, response);
                                    roundedBitmap.setCircular(true);
                                    mCallback.onImageLoaded(roundedBitmap.getBitmap());
                                } else {
                                    mCallback.onImageLoaded(response);
                                }

                            }

                        });

                    }
                }

                private boolean drawTile(Canvas canvas, String letter, int tileColor, int left, int top,
                        int right, int bottom) {
                    letter = letter.toUpperCase(Locale.getDefault());
                    Paint tilePaint = new Paint(), textPaint = new Paint();
                    tilePaint.setColor(tileColor);
                    textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
                    textPaint.setColor(FG_COLOR);
                    textPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
                    textPaint.setTextSize((float) ((right - left) * 0.8));
                    Rect rect = new Rect();

                    canvas.drawRect(new Rect(left, top, right, bottom), tilePaint);
                    textPaint.getTextBounds(letter, 0, 1, rect);
                    float width = textPaint.measureText(letter);
                    canvas.drawText(letter, (right + left) / 2 - width / 2,
                            (top + bottom) / 2 + rect.height() / 2, textPaint);
                    return true;
                }

                private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) {
                    if (name != null) {
                        final String letter = getFirstLetter(name);
                        final int color = ThumbnailsCacheManager.getColorForName(name);
                        drawTile(canvas, letter, color, left, top, right, bottom);
                        return true;
                    }
                    return false;
                }

            });
    httpConnection.setBitmap();
    httpConnection.send();
}