Example usage for android.graphics Typeface BOLD_ITALIC

List of usage examples for android.graphics Typeface BOLD_ITALIC

Introduction

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

Prototype

int BOLD_ITALIC

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

Click Source Link

Usage

From source file:Main.java

public static int toTypefaceStyle(String fontWeight, 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;//  w ww . ja v  a 2s.c o m
            }
        } 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.github.fountaingeyser.typefacecompat.TypefaceCompat.java

public static Typeface create(Context ctx, String familyName, int style) {
    if (isSupported(familyName)) {
        boolean styleAfterwards = false;
        String fileName = FONT_FAMILY_FILE_PREFIX.get(familyName);
        if (fileName.endsWith("-")) {
            // All styles are supported.
            fileName += STYLE_SUFFIX[style];
        } else {/* ww w. ja  va 2s.c o  m*/
            switch (style) {
            case Typeface.NORMAL:
                break;
            case Typeface.BOLD:
            case Typeface.BOLD_ITALIC:
                // These styles are not supported by default. Therefore force style after retrieving normal font.
                styleAfterwards = true;
                break;
            case Typeface.ITALIC:
                fileName += STYLE_SUFFIX[style];
                break;
            }
        }
        fileName += TTF_SUFFIX;
        // Retrieve Typeface from cache.
        Typeface tf = TYPEFACE_CACHE.get(fileName);
        if (tf == null) {
            // Create Typeface and cache it for later.
            String fontPath = "fonts/" + fileName;
            tf = Typeface.createFromAsset(ctx.getAssets(), fontPath);
            if (tf != null) {
                TYPEFACE_CACHE.put(fileName, tf);
            }
        }
        if (tf != null) {
            return styleAfterwards ? Typeface.create(tf, style) : tf;
        }
    }
    // Let the default implementation of Typeface try.
    return Typeface.create(familyName, style);
}

From source file:org.cyanogenmod.theme.chooser.FontPreviewFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPkgName = getArguments().getString(PKG_EXTRA);

    ThemedTypefaceHelper helper = new ThemedTypefaceHelper();
    helper.load(getActivity(), mPkgName);
    mTypefaceNormal = helper.getTypeface(Typeface.NORMAL);
    mTypefaceBold = helper.getTypeface(Typeface.BOLD);
    mTypefaceItalic = helper.getTypeface(Typeface.ITALIC);
    mTypefaceBoldItalic = helper.getTypeface(Typeface.BOLD_ITALIC);
}

From source file:com.example.SmartBoard.MyActivity.java

/**
 * Called when the activity is first created.
 *//*from   www .  j a va2 s. com*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    handler.usersAdapter = new UserListArrayAdapter(this, R.layout.online_list_message,
            handler.usersListHistory);
    listView = (ListView) findViewById(R.id.usersListView);

    getActionBar().setDisplayHomeAsUpEnabled(false); //disables up navigation

    TextView header = new TextView(this);
    header.setBackgroundColor(Color.parseColor("#FFF5EE"));

    header.setText("Designers:");
    header.setTypeface(null, Typeface.BOLD_ITALIC);

    header.setText(Html.fromHtml("<font color ='black'>D</font>" + "<font color ='blue'>e</font>"
            + "<font color = 'black'>s</font>" + "<font color ='red'>i</font>"
            + "<font color = 'black'>g</font>" + "<font color ='magenta'>n</font>"
            + "<font color = 'black'>e</font>" + "<font color ='blue'>r</font>"
            + "<font  color = 'black'>s</font>" + "<font color = 'black'>:</font>"

    ));

    listView.addHeaderView(header, "Online", false);
    listView.setAdapter(handler.usersAdapter);

    // handler.registerResources(getApplicationContext());
    drawer = (DrawingView) findViewById(R.id.drawing);
    handler.passDrawingContext(this);
}

From source file:com.android.tabletcustomui.views.LeftCircleContainer.java

private void init(Context context, int width) {

    LinearLayoutCompat.LayoutParams layoutParams = new LinearLayoutCompat.LayoutParams((int) (width),
            (int) (width));
    layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL;
    this.setLayoutParams(layoutParams);

    LeftOuterCircleView leftOuterCircleView1 = new LeftOuterCircleView(context, width, false);
    LeftOuterCircleView leftOuterCircleView2 = new LeftOuterCircleView(context, (width - 40), true);

    circleTitleView = new CircleTitleView(context, (int) (width));
    circleTitleView.setTextColor(getContext().getResources().getColor(android.R.color.white));
    circleTitleView.setTextSize(20);/*from w  w  w  .j ava2s .  c  o  m*/
    circleTitleView.setTypeface(Typeface.DEFAULT, Typeface.BOLD_ITALIC);
    circleTitleView.setText("App Name");

    this.addView(leftOuterCircleView1);
    this.addView(leftOuterCircleView2);
    addCircle(1, width - 78, (float) 0.0, 0.85);
    addCircle(2, width - 150, (float) 0.0, 0.97);
    addCircle(3, width - 170, (float) 0.0, 0.97);
    addCircle(4, width - 190, (float) 0.0, 0.98);
    addCircle(5, width - 210, (float) 0.0, 0.98);
    addCircle(6, width - 230, (float) 0.0, 0.85);
    addCircle(7, width - 280, (float) 0.0, 0.85);
    addCircle(0, width - 35, (float) 0.0, 0.9);
    addCircle(0, width - 92, (float) 0.1, 0.9);

    this.addView(circleTitleView);

    animateClockWise(leftOuterCircleView1);

    animateAntiClockWise(leftOuterCircleView2);

}

From source file:com.money.manager.ex.reports.PayeeReportFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    setListAdapter(null);//from w  w  w.  java  2  s. co m
    setSearchMenuVisible(true);

    //create header view
    mHeaderListView = (LinearLayout) addListViewHeaderFooter(R.layout.item_generic_report_2_columns);
    TextView txtColumn1 = (TextView) mHeaderListView.findViewById(R.id.textViewColumn1);
    TextView txtColumn2 = (TextView) mHeaderListView.findViewById(R.id.textViewColumn2);
    //set header
    txtColumn1.setText(R.string.payee);
    txtColumn1.setTypeface(null, Typeface.BOLD);
    txtColumn2.setText(R.string.amount);
    txtColumn2.setTypeface(null, Typeface.BOLD);
    //add to list view
    getListView().addHeaderView(mHeaderListView);

    //create footer view
    mFooterListView = (LinearLayout) addListViewHeaderFooter(R.layout.item_generic_report_2_columns);
    txtColumn1 = (TextView) mFooterListView.findViewById(R.id.textViewColumn1);
    txtColumn2 = (TextView) mFooterListView.findViewById(R.id.textViewColumn2);
    //set footer
    txtColumn1.setText(R.string.total);
    txtColumn1.setTypeface(null, Typeface.BOLD_ITALIC);
    txtColumn2.setText(R.string.total);
    txtColumn2.setTypeface(null, Typeface.BOLD_ITALIC);
    //add to list view
    //getListView().addFooterView(mFooterListView);

    //set adapter
    PayeeReportAdapter adapter = new PayeeReportAdapter(getActivity(), null);
    setListAdapter(adapter);

    super.onActivityCreated(savedInstanceState);
}

From source file:com.money.manager.ex.reports.CategoriesReportFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    setListAdapter(null);//from  w w  w .j a  va 2s  .c  o  m
    setSearchMenuVisible(true);

    //create header view
    LinearLayout mListViewHeader = (LinearLayout) addListViewHeaderFooter(
            R.layout.item_generic_report_2_columns);
    TextView txtColumn1 = (TextView) mListViewHeader.findViewById(R.id.textViewColumn1);
    TextView txtColumn2 = (TextView) mListViewHeader.findViewById(R.id.textViewColumn2);
    //set header
    txtColumn1.setText(R.string.category);
    txtColumn1.setTypeface(null, Typeface.BOLD);
    txtColumn2.setText(R.string.amount);
    txtColumn2.setTypeface(null, Typeface.BOLD);
    //add to list view
    getListView().addHeaderView(mListViewHeader);

    //create footer view
    mListViewFooter = (LinearLayout) addListViewHeaderFooter(R.layout.item_generic_report_2_columns);
    txtColumn1 = (TextView) mListViewFooter.findViewById(R.id.textViewColumn1);
    txtColumn2 = (TextView) mListViewFooter.findViewById(R.id.textViewColumn2);
    //set footer
    txtColumn1.setText(R.string.total);
    txtColumn1.setTypeface(null, Typeface.BOLD_ITALIC);
    txtColumn2.setText(R.string.total);
    txtColumn2.setTypeface(null, Typeface.BOLD_ITALIC);

    //add to list view --> move to load finished
    //getListView().addFooterView(mListViewFooter);

    //set adapter
    CategoriesReportAdapter adapter = new CategoriesReportAdapter(getActivity(), null);
    setListAdapter(adapter);
    //call super method
    super.onActivityCreated(savedInstanceState);
}

From source file:br.com.frs.foodrestrictions.FoodMessages.java

@SuppressLint("SetTextI18n")
private void refreshMessages(View v) {

    int nAllergic = 0;
    int nDontEat = 0;

    llAllergic.removeAllViews();/*from  ww  w . j av a 2 s  . co  m*/
    llDontEat.removeAllViews();

    for (final FoodIconItem iconItem : restrictList) {
        final String foodName = getResources().getString(iconItem.getNameId());
        final String allergic_text = getResources().getString(R.string.allergic_to) + " " + foodName;
        final String dont_eat_text = getResources().getString(R.string.dont_eat) + " " + foodName;

        TextView tv = new TextView(v.getContext());
        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tv.setTypeface(null, Typeface.BOLD_ITALIC);
        tv.setText("* " + foodName);

        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (iconItem.getRestrictionType()) {
                case FoodIconList.FOOD_RESTRICTION_TYPE_ALLERGIC:
                    Snackbar.make(v, allergic_text, Snackbar.LENGTH_LONG).setAction("Action", null).show();
                    break;
                case FoodIconList.FOOD_RESTRICTION_TYPE_DONT_EAT:
                    Snackbar.make(v, dont_eat_text, Snackbar.LENGTH_LONG).setAction("Action", null).show();
                    break;
                }
            }
        });

        if (iconItem.getRestrictionType() == FoodIconList.FOOD_RESTRICTION_TYPE_ALLERGIC) {
            llAllergic.addView(tv);
            ++nAllergic;
        } else {
            llDontEat.addView(tv);
            ++nDontEat;
        }

    }

    if (nAllergic == 0) {
        allergicText.setVisibility(View.GONE);

        TextView tv = new TextView(v.getContext());
        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tv.setTypeface(null, Typeface.BOLD_ITALIC);
        tv.setText("* " + getResources().getString(R.string.food_msg_not_allergic));
        llAllergic.addView(tv);
    } else {
        allergicText.setText(getResources().getString(R.string.message_allergic_to));
    }

    if (nDontEat == 0) {
        dontEatText.setVisibility(View.GONE);

        TextView tv = new TextView(v.getContext());
        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tv.setTypeface(null, Typeface.BOLD_ITALIC);
        tv.setText("* " + getResources().getString(R.string.food_msg_not_picker));
        llDontEat.addView(tv);
    } else {
        dontEatText.setText(getResources().getString(R.string.message_dont_eat));
    }
}

From source file:com.tr4android.support.extension.typeface.TypefaceCompat.java

/**
 * Creates a typeface object that best matches the specified typeface and the specified style.
 * Use this call if you want to pick a new style from the same family of an typeface object.
 * If family is null, this selects from the default font's family.
 *
 * @param ctx        A context.//ww w.  jav a 2s.  c om
 * @param familyName May be null. The name of the font family.
 * @param style      The style (normal, bold, italic) of the typeface, e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC.
 * @return The best matching typeface.
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
public static Typeface create(Context ctx, String familyName, int style) {
    if (!mInitialized)
        initialize();
    if (isSupported(familyName) || familyName == null) {
        boolean styleAfterwards = false;
        String fileName = FONT_FAMILY_FILE_PREFIX.get(familyName == null ? "sans-serif" : familyName);
        if (fileName.endsWith("-")) {
            // All styles are supported.
            fileName += STYLE_SUFFIX[style];
        } else {
            switch (style) {
            case Typeface.NORMAL:
                break;
            case Typeface.BOLD:
            case Typeface.BOLD_ITALIC:
                // These styles are not supported by default. Therefore force style after retrieving normal font.
                styleAfterwards = true;
                break;
            case Typeface.ITALIC:
                fileName += STYLE_SUFFIX[style];
                break;
            }
        }
        fileName += TTF_SUFFIX;
        // Retrieve Typeface from cache.
        Typeface tf = TYPEFACE_CACHE.get(fileName);
        if (tf == null) {
            // Create Typeface and cache it for later.
            String fontPath = "fonts/" + fileName;
            tf = Typeface.createFromAsset(ctx.getAssets(), fontPath);
            if (tf != null) {
                TYPEFACE_CACHE.put(fileName, tf);
            }
        }
        if (tf != null) {
            return styleAfterwards ? Typeface.create(tf, style) : tf;
        }
    }
    // Let the default implementation of Typeface try.
    return Typeface.create(familyName, style);
}

From source file:com.mehdi.graphview.custom.SimpleLineGraph.java

@Override
public void onFinished(TickerList tickerList) {

    if (null == tickerList) {
        return;//from  www .  jav  a  2 s  . com
    }

    GraphView graphView = (GraphView) rootView.findViewById(R.id.graph);
    LineGraphSeries<DataPoint> series = new LineGraphSeries<>();

    ArrayList<Tickers> tickers = tickerList.tickers;
    ArrayList<DataPoint> dataPointArrayList = new ArrayList<>();
    for (int i = 0; i < tickers.get(0).historical.size(); i++) {
        dataPointArrayList.add(new DataPoint(i,
                //Double.parseDouble(String.valueOf(tickers.get(0).historical.get(i).get(0))),
                Double.parseDouble(String.valueOf(tickers.get(0).historical.get(i).get(1)))));
    }

    DataPoint[] dataPoints = dataPointArrayList.toArray(new DataPoint[dataPointArrayList.size()]);

    series.resetData(dataPoints);
    graphView.addSeries(series);

    // set manual X bounds
    graphView.getViewport().setXAxisBoundsManual(true);
    graphView.getViewport().setMinX(0);
    graphView.getViewport().setMaxX(series.getHighestValueX());

    // set manual Y bounds
    graphView.getViewport().setYAxisBoundsManual(true);
    graphView.getViewport().setMinY(series.getLowestValueY());
    graphView.getViewport().setMaxY(series.getHighestValueY());

    graphView.getViewport().setScrollable(false);

    StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graphView);

    // set xLabels values
    int middleIndex = tickers.get(0).historical.size() / 2;
    staticLabelsFormatter.setHorizontalLabels(new String[] {
            getHourMinute(String.valueOf(tickers.get(0).historical.get(0).get(0))), "",
            getHourMinute(String.valueOf(tickers.get(0).historical.get(middleIndex).get(0))), "",
            getHourMinute(String
                    .valueOf(tickers.get(0).historical.get(tickers.get(0).historical.size() - 1).get(0))) });

    staticLabelsFormatter.setVerticalLabels(new String[] { "", "", "" });

    graphView.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
    //        graphView.getGridLabelRenderer().setTextSize(35);
    //        graphView.getGridLabelRenderer().setTextSize(25);
    float spToFloat = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 25,
            graphView.getContext().getResources().getDisplayMetrics());
    graphView.getGridLabelRenderer().setTextSize(spToFloat);

    // setting label typeface
    if (null != getContext()) {
        Typeface plain = Typeface.createFromAsset(getContext().getAssets(),
                "SouthernAire_Personal_Use_Only.ttf");
        Typeface typeface = Typeface.create(plain, Typeface.BOLD_ITALIC);
        graphView.getGridLabelRenderer().setLabelTypeface(typeface);
    }

    // set second scale. This one is used to show the vertical labels
    // on the right side as per UI Spec.
    graphView.getSecondScale().setMinY(getMinimumValue(tickers.get(0).historical));
    graphView.getSecondScale().setMaxY(getMaximumValue(tickers.get(0).historical));
    graphView.getGridLabelRenderer().setVerticalLabelsSecondScaleAlign(Paint.Align.CENTER);

    if (null != getContext()) {
        int colorStockLabelGray = Color.GRAY;
        graphView.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(colorStockLabelGray);
        graphView.getGridLabelRenderer().setHorizontalLabelsColor(colorStockLabelGray);
        graphView.getGridLabelRenderer().setGridColor(colorStockLabelGray);
    }

    graphView.getGridLabelRenderer().setHighlightZeroLines(false);
    graphView.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.VERTICAL);
    graphView.getGridLabelRenderer().reloadStyles();
    //series.setColor(Color.GREEN);
    series.setColor(Color.WHITE);
}