Example usage for android.graphics Typeface DEFAULT_BOLD

List of usage examples for android.graphics Typeface DEFAULT_BOLD

Introduction

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

Prototype

Typeface DEFAULT_BOLD

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

Click Source Link

Document

The default BOLD typeface object.

Usage

From source file:busradar.madison.StopDialog.java

StopDialog(final Context ctx, final int stopid, final int lat, final int lon) {
    super(ctx);//from  w  w w.j  a  va 2s. c  o m
    this.stopid = stopid;

    // getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
    getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

    final String name = DB.getStopName(stopid);
    setTitle(name);

    routes = get_time_urls(StopDialog.this.stopid);

    // getWindow().setLayout(LayoutParams.FILL_PARENT,
    // LayoutParams.FILL_PARENT);

    setContentView(new RelativeLayout(ctx) {
        {
            addView(new TextView(ctx) {
                {
                    setId(stop_num_id);
                    setText(Html.fromHtml(String.format(
                            "[<a href='http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf'>%04d</a>]",
                            stopid, stopid)));
                    setPadding(0, 0, 5, 0);
                    this.setMovementMethod(LinkMovementMethod.getInstance());
                }
            }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) {
                {
                    addRule(ALIGN_PARENT_RIGHT);
                }
            });

            addView(new ImageView(ctx) {
                boolean enabled;

                @Override
                public void setEnabled(boolean e) {
                    enabled = e;

                    setImageResource(e ? R.drawable.love_enabled : R.drawable.love_disabled);
                    if (e) {
                        G.favorites.add_favorite_stop(stopid, name, lat, lon);
                        Toast.makeText(ctx, "Added stop to Favorites", Toast.LENGTH_SHORT).show();
                    } else {
                        G.favorites.remove_favorite_stop(stopid);
                        Toast.makeText(ctx, "Removed stop from Favorites", Toast.LENGTH_SHORT).show();
                    }
                }

                {
                    enabled = G.favorites.is_stop_favorite(stopid);
                    setImageResource(enabled ? R.drawable.love_enabled : R.drawable.love_disabled);

                    setPadding(0, 0, 10, 0);
                    setOnClickListener(new OnClickListener() {
                        public void onClick(View v) {
                            setEnabled(!enabled);
                        }
                    });
                }
            }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) {
                {
                    addRule(LEFT_OF, stop_num_id);
                    setMargins(0, -3, 0, 0);
                }
            });

            addView(cur_loading_text = new TextView(ctx) {
                {
                    setText("Loading...");
                    setPadding(5, 0, 0, 0);
                }
            });
            addView(new HorizontalScrollView(ctx) {
                {
                    setId(route_list_id);
                    setHorizontalScrollBarEnabled(false);

                    addView(new LinearLayout(ctx) {
                        float text_size;
                        Button cur_button;
                        {
                            int last_route = -1;
                            for (int i = 0; i < routes.length; i++) {

                                final RouteURL route = routes[i];

                                if (route.route == last_route)
                                    continue;
                                last_route = route.route;

                                addView(new Button(ctx) {
                                    public void setEnabled(boolean e) {
                                        if (e) {
                                            setBackgroundColor(0xff000000 | G.route_points[route.route].color);
                                            setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size * 1.5f);
                                        } else {
                                            setBackgroundColor(0x90000000 | G.route_points[route.route].color);
                                            setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size);
                                        }
                                    }

                                    {
                                        setText(G.route_points[route.route].name);
                                        setTextColor(0xffffffff);
                                        setTypeface(Typeface.DEFAULT_BOLD);
                                        text_size = getTextSize();

                                        if (G.active_route == route.route) {
                                            setEnabled(true);
                                            cur_button = this;
                                        } else
                                            setEnabled(false);

                                        final Button b = this;

                                        setOnClickListener(new OnClickListener() {
                                            public void onClick(View v) {
                                                if (cur_button != null) {
                                                    cur_button.setEnabled(false);
                                                }

                                                if (cur_button == b) {
                                                    cur_button.setEnabled(false);
                                                    cur_button = null;

                                                    selected_route = null;
                                                    update_time_display();
                                                } else {
                                                    cur_button = b;
                                                    cur_button.setEnabled(true);

                                                    selected_route = route;
                                                    update_time_display();
                                                }
                                            }
                                        });

                                    }
                                });
                            }
                        }
                    });
                }
            }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {
                {
                    addRule(RelativeLayout.BELOW, stop_num_id);
                    addRule(RelativeLayout.CENTER_HORIZONTAL);
                }
            });

            addView(status_text = new TextView(ctx) {
                {
                    setText("");
                }
            }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {
                {
                    addRule(RelativeLayout.BELOW, route_list_id);
                    addRule(RelativeLayout.CENTER_HORIZONTAL);
                }
            });
            addView(list_view = new ListView(ctx) {
                {
                    setId(time_list_id);
                    setVerticalScrollBarEnabled(false);
                    setAdapter(times_adapter = new BaseAdapter() {

                        public View getView(final int position, View convertView, ViewGroup parent) {
                            CellView v;

                            if (convertView == null)
                                v = new CellView(ctx);
                            else
                                v = (CellView) convertView;

                            RouteTime rt = curr_times.get(position);
                            v.setBackgroundColor(G.route_points[rt.route].color | 0xff000000);
                            v.route_textview.setText(G.route_points[rt.route].name);
                            if (rt.dir != null)
                                v.dir_textview.setText("to " + rt.dir);
                            v.time_textview.setText(rt.time);

                            return v;

                        }

                        public int getCount() {
                            return curr_times.size();
                        }

                        public Object getItem(int position) {
                            return null;
                        }

                        public long getItemId(int position) {
                            return 0;
                        }

                    });
                }
            }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) {
                {
                    addRule(RelativeLayout.BELOW, route_list_id);
                }
            });
        }
    });

    TextView title = (TextView) findViewById(android.R.id.title);
    title.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    title.setSelected(true);
    title.setTextColor(0xffffffff);
    title.setMarqueeRepeatLimit(-1);

    // getWindow().set, value)
    // getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
    // android.R.drawable.ic_dialog_info);

    // title.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);

    if (G.active_route >= 0)
        for (int i = 0; i < routes.length; i++)
            if (routes[i].route == G.active_route) {
                selected_route = routes[i];

                RouteURL[] rnew = new RouteURL[routes.length];
                rnew[0] = selected_route;

                for (int j = 0, k = 1; j < routes.length; j++)
                    if (j != i)
                        rnew[k++] = routes[j];

                routes = rnew;
                break;
            }
    update_time_display();
}

From source file:com.googlecode.android_scripting.activity.Main.java

protected void initializeViews() {
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    TextView textview = new TextView(this);
    textview.setText(" PhpForAndroid " + version);
    ImageView imageView = new ImageView(this);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa));
    layout.addView(imageView);//  www.j a  v a  2 s  . c o  m
    mButton = new Button(this);
    mAboutButton = new Button(this);
    MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    final float scale = getResources().getDisplayMetrics().density;
    int marginPixels = (int) (MARGIN_DIP * scale + 0.5f);
    marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels);
    mButton.setLayoutParams(marginParams);
    mAboutButton.setLayoutParams(marginParams);
    layout.addView(textview);
    layout.addView(mButton);
    layout.addView(mAboutButton);

    mProgressLayout = new LinearLayout(this);
    mProgressLayout.setOrientation(LinearLayout.HORIZONTAL);
    mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

    LinearLayout bottom = new LinearLayout(this);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    bottom.setGravity(Gravity.CENTER_VERTICAL);
    mProgressLayout.addView(bottom);

    TextView message = new TextView(this);
    message.setText("   In Progress...");
    message.setTextSize(20);
    message.setTypeface(Typeface.DEFAULT_BOLD);
    message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    ProgressBar bar = new ProgressBar(this);
    bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    bottom.addView(bar);
    bottom.addView(message);
    mProgressLayout.setVisibility(View.INVISIBLE);

    layout.addView(mProgressLayout);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminateVisibility(false);

    setContentView(layout);
}

From source file:com.androprogrammer.tutorials.customviews.SlidingTabLayout.java

protected TextView createDefaultTextTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    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);
    }/*from   w ww  .  j a v  a 2 s  . co  m*/

    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(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    //System.out.println("c " + titleColor);
    if (titleColor != null) {
        textView.setTextColor(titleColor);
    }

    return textView;
}

From source file:com.kyleszombathy.sms_scheduler.Home.java

private Bitmap createCircleImageFromFirstLetterOfName(String firstName) {
    // Get color// w  ww .j a va  2s .  c  o  m
    ColorGenerator generator = ColorGenerator.MATERIAL;
    int color = generator.getColor(firstName); //Always use same color for a specific person
    TextDrawable drawable = TextDrawable.builder(this).beginConfig().useFont(Typeface.DEFAULT_BOLD)
            .fontSize(circleImageViewTextSize).height(circleImageViewWidth).width(circleImageViewWidth)
            .endConfig().buildRound(Character.toString(firstName.charAt(0)).toUpperCase(), color);
    return Tools.drawableToBitmap(drawable); // Convert to bitmap
}

From source file:com.socialinfotech.tabbar.smart.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)}./* ww  w.  j av a 2 s  .  com*/
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    textView.setTextColor(mTabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    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(mTabViewTextAllCaps);
    }

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

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

    return textView;
}

From source file:com.doomy.padlock.MainFragment.java

public void snackBar(int mColor) {
    mMultipleActions = (FloatingActionsMenu) getView().findViewById(R.id.multipleActions);
    SnackbarManager.show(Snackbar.with(getActivity()).text(getString(R.string.reboot))
            .textColor(getResources().getColor(R.color.greyMaterialDark))
            .color(getResources().getColor(R.color.greyMaterialLight)).eventListener(new EventListener() {
                @Override/*  w  w  w  .  j a  v  a2s  .  co  m*/
                public void onShow(Snackbar snackbar) {
                    if (android.os.Build.DEVICE.equals("mako")) {
                        mMultipleActions.animate().translationY(-snackbar.getHeight()); // Nexus 4
                    } else if (android.os.Build.DEVICE.equals("hammerhead")) {
                        mMultipleActions.animate().translationY(-snackbar.getHeight()); // Nexus 5
                    } else if (android.os.Build.DEVICE.equals("bacon")
                            || android.os.Build.DEVICE.equals("A0001")) {
                        mMultipleActions.animate().translationY(-snackbar.getHeight()); // OnePlus One
                    }
                }

                @Override
                public void onShowByReplace(Snackbar snackbar) {

                }

                @Override
                public void onShown(Snackbar snackbar) {

                }

                @Override
                public void onDismiss(Snackbar snackbar) {
                    if (android.os.Build.DEVICE.equals("mako")) {
                        mMultipleActions.animate().translationY(0); // Nexus 4
                    } else if (android.os.Build.DEVICE.equals("hammerhead")) {
                        mMultipleActions.animate().translationY(0); // Nexus 5
                    } else if (android.os.Build.DEVICE.equals("bacon")
                            || android.os.Build.DEVICE.equals("A0001")) {
                        mMultipleActions.animate().translationY(0); // OnePlus One
                    }
                }

                @Override
                public void onDismissByReplace(Snackbar snackbar) {

                }

                @Override
                public void onDismissed(Snackbar snackbar) {

                }
            }).actionLabel(getString(R.string.yes)).actionLabelTypeface(Typeface.DEFAULT_BOLD)
            .actionColor(mColor).actionListener(new ActionClickListener() {
                @Override
                public void onActionClicked(Snackbar snackbar) {
                    superUserReboot(mRebootBootLoader);
                }
            }).duration(Snackbar.SnackbarDuration.LENGTH_LONG));
}

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();// w  ww  .  j  a  va2  s  .  co  m
}

From source file:com.cssweb.android.view.FinanceMini.java

public void drawHKIndex(Canvas canvas) {
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);//from   w ww .ja  v a2  s  .  co  m
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setTextSize(mTextSize);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width, -DY * 3);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("zj")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceEqual);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("pj")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("dj")), x - tips, y, paint);

        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.it520.activity.main.wight.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  av a  2 s .  com*/
 */
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_BOLD);
    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:cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper.java

/**
 * ?/*from   www . j  a  v  a2  s  .  co m*/
 *
 * @param viewId
 * @param isBold
 * @return
 */
public BGAViewHolderHelper setBold(@IdRes int viewId, boolean isBold) {
    getTextView(viewId).getPaint().setTypeface(isBold ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    return this;
}