Example usage for android.graphics Typeface DEFAULT

List of usage examples for android.graphics Typeface DEFAULT

Introduction

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

Prototype

Typeface DEFAULT

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

Click Source Link

Document

The default NORMAL typeface object

Usage

From source file:com.open.imooc.widght.tab.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.// w  w  w . j a  va2s .c  o  m
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    //        textView.setTextColor(tabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (tabViewBackgroundResId != NO_ID) {
        textView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(tabViewTextAllCaps);
    }

    textView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        textView.setMinWidth(tabViewTextMinWidth);
    }

    return textView;
}

From source file:com.limewoodmedia.nsdroid.activities.Nation.java

private void setUpChartRenderer(DefaultRenderer chartRenderer) {
    Resources r = getResources();
    float labelTextSize = r.getDimension(R.dimen.pie_chart_label_size);

    chartRenderer.setZoomButtonsVisible(false);
    chartRenderer.setStartAngle(-90);//  ww  w .ja v a  2  s.c  om
    chartRenderer.setDisplayValues(true);
    chartRenderer.setClickEnabled(true);
    chartRenderer.setInScroll(true);
    chartRenderer.setAntialiasing(true);
    chartRenderer.setLabelsTextSize(labelTextSize);
    //        chartRenderer.setLegendTextSize(labelTextSize);
    chartRenderer.setShowLegend(false);
    chartRenderer.setTextTypeface(Typeface.DEFAULT);
    chartRenderer.setZoomRate(6);
    chartRenderer.setPanEnabled(false);
    chartRenderer.setLabelsColor(android.graphics.Color.BLACK);
    chartRenderer.setMargins(new int[] { Math.round(r.getDimension(R.dimen.pie_chart_margin_top)),
            Math.round(r.getDimension(R.dimen.pie_chart_margin_left)),
            Math.round(r.getDimension(R.dimen.pie_chart_margin_bottom)),
            Math.round(r.getDimension(R.dimen.pie_chart_margin_right)) });
}

From source file:org.cocos2dx.lib.Cocos2dxBitmap.java

private static int getFontSizeAccordingHeight(int height) {
    Paint paint = new Paint();
    Rect bounds = new Rect();

    paint.setTypeface(Typeface.DEFAULT);
    int incr_text_size = 1;
    boolean found_desired_size = false;

    while (!found_desired_size) {

        paint.setTextSize(incr_text_size);
        String text = "SghMNy";
        paint.getTextBounds(text, 0, text.length(), bounds);

        incr_text_size++;/*  www. j a  v a 2  s  . c o m*/

        if (height - bounds.height() <= 2) {
            found_desired_size = true;
        }
        Log.d("font size", "incr size:" + incr_text_size);
    }
    return incr_text_size;
}

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

public Typeface getCollapsedTypeface() {
    return mCollapsedTypeface != null ? mCollapsedTypeface : Typeface.DEFAULT;
}

From source file:com.manuelpeinado.numericpageindicator.NumericPageIndicator.java

public void setPageNumberTextBold(boolean pageNumberTextBold) {
    mPageNumberTextBold = pageNumberTextBold;
    final Typeface typeface = mPageNumberTextBold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT;
    mPaintPageNumberText.setTypeface(typeface);
    invalidate();/*from  ww w.  ja  v  a 2 s  .c o  m*/
}

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

public Typeface getExpandedTypeface() {
    return mExpandedTypeface != null ? mExpandedTypeface : Typeface.DEFAULT;
}

From source file:com.jjoe64.graphview_demos.fragments.StartSensors.java

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_WORD_LIST_ACTIVITY) {
            if (resultCode == getActivity().RESULT_OK) {
                try {
                    String strWord = data.getStringExtra("word");
                    //etWrite.setText(strWord);
                    // Set a cursor position last
                    //etWrite.setSelection(etWrite.getText().length());
                } catch (Exception e) {
                    Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
                }//w  w  w .  ja v a  2  s  . c o m
            }
        } else if (requestCode == REQUEST_PREFERENCE) {

            SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());

            String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
            mDisplayType = Integer.valueOf(res);

            res = pref.getString("fontsize_list", Integer.toString(12));
            mTextFontSize = Integer.valueOf(res);
            //mTvSerial.setTextSize(mTextFontSize);

            res = pref.getString("typeface_list", Integer.toString(3));
            switch (Integer.valueOf(res)) {
            case 0:
                mTextTypeface = Typeface.DEFAULT;
                break;
            case 1:
                mTextTypeface = Typeface.SANS_SERIF;
                break;
            case 2:
                mTextTypeface = Typeface.SERIF;
                break;
            case 3:
                mTextTypeface = Typeface.MONOSPACE;
                break;
            }
            //mTvSerial.setTypeface(mTextTypeface);
            //etWrite.setTypeface(mTextTypeface);

            res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
            mReadLinefeedCode = Integer.valueOf(res);

            res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
            mWriteLinefeedCode = Integer.valueOf(res);

            res = pref.getString("email_edittext", "@gmail.com");
            mEmailAddress = res;

            int intRes;

            res = pref.getString("baudrate_list", Integer.toString(57600));
            intRes = Integer.valueOf(res);
            if (mBaudrate != intRes) {

                mBaudrate = intRes;
                mSerial.setBaudrate(mBaudrate);
            }

            res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
            intRes = Integer.valueOf(res);
            if (mDataBits != intRes) {
                mDataBits = Integer.valueOf(res);
                mSerial.setDataBits(mDataBits);
            }

            res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
            intRes = Integer.valueOf(res);
            if (mParity != intRes) {
                mParity = intRes;
                mSerial.setParity(mParity);
            }

            res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
            intRes = Integer.valueOf(res);
            if (mStopBits != intRes) {
                mStopBits = intRes;
                mSerial.setStopBits(mStopBits);
            }

            res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
            intRes = Integer.valueOf(res);
            if (mFlowControl != intRes) {
                mFlowControl = intRes;
                if (mFlowControl == UartConfig.FLOW_CONTROL_ON) {
                    mSerial.setDtrRts(true, true);
                } else {
                    mSerial.setDtrRts(false, false);
                }
            }

            /*
            res = pref.getString("break_list", Integer.toString(FTDriver.FTDI_SET_NOBREAK));
            intRes = Integer.valueOf(res) << 14;
            if (mBreak != intRes) {
            mBreak = intRes;
            mSerial.setSerialPropertyBreak(mBreak, FTDriver.CH_A);
            mSerial.setSerialPropertyToChip(FTDriver.CH_A);
            }
            */
        }
    }

From source file:org.cocos2dx.lib.Cocos2dxBitmap.java

private static String getStringWithEllipsis(String originalText, float width, float fontSize) {
    if (TextUtils.isEmpty(originalText)) {
        return "";
    }//from w w w . j  av  a 2  s.  c o  m

    TextPaint paint = new TextPaint();
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(fontSize);

    return TextUtils.ellipsize(originalText, paint, width, TextUtils.TruncateAt.valueOf("END")).toString();
}

From source file:com.jjoe64.graphview_demos.fragments.CollectData.java

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_WORD_LIST_ACTIVITY) {
            if (resultCode == getActivity().RESULT_OK) {
                try {
                    String strWord = data.getStringExtra("word");
                    //etWrite.setText(strWord);
                    // Set a cursor position last
                    //etWrite.setSelection(etWrite.getText().length());
                } catch (Exception e) {
                    Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
                }/*from   w  ww. j a  v  a  2  s .  c o  m*/
            }
        } else if (requestCode == REQUEST_PREFERENCE) {

            SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());

            String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
            mDisplayType = Integer.valueOf(res);

            res = pref.getString("fontsize_list", Integer.toString(12));
            mTextFontSize = Integer.valueOf(res);
            mTvSerial.setTextSize(mTextFontSize);

            res = pref.getString("typeface_list", Integer.toString(3));
            switch (Integer.valueOf(res)) {
            case 0:
                mTextTypeface = Typeface.DEFAULT;
                break;
            case 1:
                mTextTypeface = Typeface.SANS_SERIF;
                break;
            case 2:
                mTextTypeface = Typeface.SERIF;
                break;
            case 3:
                mTextTypeface = Typeface.MONOSPACE;
                break;
            }
            mTvSerial.setTypeface(mTextTypeface);
            //            etWrite.setTypeface(mTextTypeface);

            res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
            mReadLinefeedCode = Integer.valueOf(res);

            res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
            mWriteLinefeedCode = Integer.valueOf(res);

            res = pref.getString("email_edittext", "@gmail.com");
            mEmailAddress = res;

            int intRes;

            res = pref.getString("baudrate_list", Integer.toString(57600));
            intRes = Integer.valueOf(res);
            if (mBaudrate != intRes) {

                mBaudrate = intRes;
                mSerial.setBaudrate(mBaudrate);
            }

            res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
            intRes = Integer.valueOf(res);
            if (mDataBits != intRes) {
                mDataBits = Integer.valueOf(res);
                mSerial.setDataBits(mDataBits);
            }

            res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
            intRes = Integer.valueOf(res);
            if (mParity != intRes) {
                mParity = intRes;
                mSerial.setParity(mParity);
            }

            res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
            intRes = Integer.valueOf(res);
            if (mStopBits != intRes) {
                mStopBits = intRes;
                mSerial.setStopBits(mStopBits);
            }

            res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
            intRes = Integer.valueOf(res);
            if (mFlowControl != intRes) {
                mFlowControl = intRes;
                if (mFlowControl == UartConfig.FLOW_CONTROL_ON) {
                    mSerial.setDtrRts(true, true);
                } else {
                    mSerial.setDtrRts(false, false);
                }
            }

            /*
            res = pref.getString("break_list", Integer.toString(FTDriver.FTDI_SET_NOBREAK));
            intRes = Integer.valueOf(res) << 14;
            if (mBreak != intRes) {
            mBreak = intRes;
            mSerial.setSerialPropertyBreak(mBreak, FTDriver.CH_A);
            mSerial.setSerialPropertyToChip(FTDriver.CH_A);
            }
            */
        }
    }

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void parseParagraphs(Elements ps) {
    for (Element p : ps) {
        if (!p.html().startsWith("&") && !p.html().startsWith("<iframe") && !p.html().startsWith("<!")
                && !p.html().contains("<h") && !p.html().contains("<ol") && !p.html().contains("<ul")
                && !p.html().contains("<pre") && !p.html().contains("<tr")) {
            parseNormalImages(p.select("img"));
            p.select("img").remove();

            Elements lnks = p.getElementsByTag("a");
            for (Element lnk : lnks) {
                if (lnk.attr("href").startsWith("#"))
                    lnk.removeAttr("href");
            }//  w  ww .  j av a 2 s .  c o  m

            String txt = p.html().replace("<br />", "").replace("\n", "").trim();
            if (txt.length() > 0)
                addText(txt, true, Typeface.DEFAULT);
        }
    }
}