List of usage examples for android.graphics Typeface BOLD
int BOLD
To view the source code for android.graphics Typeface BOLD.
Click Source Link
From source file:im.neon.util.VectorUtils.java
/** * Create an avatar bitmap from a text./* w w w . j a v a 2 s. co m*/ * * @param backgroundColor the background color. * @param text the text to display. * @param pixelsSide the avatar side in pixels * @return the generated bitmap */ private static Bitmap createAvatar(int backgroundColor, String text, int pixelsSide) { android.graphics.Bitmap.Config bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; Bitmap bitmap = Bitmap.createBitmap(pixelsSide, pixelsSide, bitmapConfig); Canvas canvas = new Canvas(bitmap); canvas.drawColor(backgroundColor); // prepare the text drawing Paint textPaint = new Paint(); textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); textPaint.setColor(Color.WHITE); // the text size is proportional to the avatar size. // by default, the avatar size is 42dp, the text size is 28 dp (not sp because it has to be fixed). textPaint.setTextSize(pixelsSide * 2 / 3); // get its size Rect textBounds = new Rect(); textPaint.getTextBounds(text, 0, text.length(), textBounds); // draw the text in center canvas.drawText(text, (canvas.getWidth() - textBounds.width() - textBounds.left) / 2, (canvas.getHeight() + textBounds.height() - textBounds.bottom) / 2, textPaint); // Return the avatar return bitmap; }
From source file:android.support.v7.widget.SwitchCompat.java
/** * Sets the typeface and style in which the text should be displayed on the * switch, and turns on the fake bold and italic bits in the Paint if the * Typeface that you provided does not have all the bits in the * style that you specified./*from w ww.j ava2s. c om*/ */ public void setSwitchTypeface(Typeface tf, int style) { if (style > 0) { if (tf == null) { tf = Typeface.defaultFromStyle(style); } else { tf = Typeface.create(tf, style); } setSwitchTypeface(tf); // now compute what (if any) algorithmic styling is needed int typefaceStyle = tf != null ? tf.getStyle() : 0; int need = style & ~typefaceStyle; mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0); mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0); } else { mTextPaint.setFakeBoldText(false); mTextPaint.setTextSkewX(0); setSwitchTypeface(tf); } }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
/** * Add header to ListView//from w w w . ja va 2s .c o m */ private View addListViewHeader() { TableRow row = (TableRow) View.inflate(getActivity(), R.layout.tablerow_income_vs_expenses, null); int[] ids = new int[] { R.id.textViewYear, R.id.textViewMonth, R.id.textViewIncome, R.id.textViewExpenses, R.id.textViewDifference }; for (int id : ids) { TextView textView = (TextView) row.findViewById(id); textView.setTypeface(null, Typeface.BOLD); textView.setSingleLine(true); } getListView().addHeaderView(row); return row; }
From source file:com.app.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param jsonObject //from ww w.j av a 2 s. c o m */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", false); } final WebView parent = this.webView; // Create dialog in new thread Runnable runnable = new Runnable() { public void run() { dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); //LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); //LinearLayout.LayoutParams forwardParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); //LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, 1.0f); LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams wvParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); LinearLayout toolbar = new LinearLayout(cordova.getActivity()); toolbar.setOrientation(LinearLayout.HORIZONTAL); /* ImageButton back = new ImageButton((Context) ctx); back.getBackground().setAlpha(0); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); back.setId(1); try { back.setImageBitmap(loadDrawable("plugins/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setLayoutParams(backParams); ImageButton forward = new ImageButton((Context) ctx); forward.getBackground().setAlpha(0); forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); forward.setId(2); try { forward.setImageBitmap(loadDrawable("plugins/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setLayoutParams(forwardParams); */ /* edittext = new EditText((Context) ctx); edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); edittext.setId(3); edittext.setSingleLine(true); edittext.setText(url); edittext.setLayoutParams(editParams); */ //edittext = new EditText((Context) ctx); //edittext.setVisibility(View.GONE); LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT, 1.0f); TextView title = new TextView(cordova.getActivity()); title.setId(1); title.setLayoutParams(titleParams); title.setGravity(Gravity.CENTER_VERTICAL); title.setTypeface(null, Typeface.BOLD); ImageButton close = new ImageButton(cordova.getActivity()); close.getBackground().setAlpha(0); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); close.setId(4); try { close.setImageBitmap(loadDrawable("plugins/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setLayoutParams(closeParams); childWebView = new WebView(cordova.getActivity()); childWebView.getSettings().setJavaScriptEnabled(true); childWebView.getSettings().setBuiltInZoomControls(true); WebViewClient client = new ChildBrowserClient(parent, ctx, title/*, edittext*/); childWebView.setWebViewClient(client); childWebView.loadUrl(url); childWebView.setId(5); childWebView.setInitialScale(0); childWebView.setLayoutParams(wvParams); childWebView.requestFocus(); childWebView.requestFocusFromTouch(); //toolbar.addView(back); //toolbar.addView(forward); //toolbar.addView(edittext); toolbar.addView(close); toolbar.addView(title); if (getShowLocationBar()) { main.addView(toolbar); } main.addView(childWebView); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; lp.verticalMargin = 0f; lp.horizontalMargin = 0f; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE TEXT ROW//from w w w . j av a 2s.co m * @param att * @param linear * @return */ public LinearLayout getDoubleTextRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(2, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t1 = new TextView(context); t1.setText(att.get("value1").equals("") ? " - " : att.get("value1")); t1.setTextSize(11); t1.setGravity(Gravity.CENTER_HORIZONTAL); t1.setPadding(2, 0, 0, 2); t1.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t1, value_one_params); LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t2 = new TextView(context); t2.setTextSize(11); t2.setText(att.get("value2").equals("") ? " - " : att.get("value2")); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t2, value_two_params); linear.addView(container_layout); return linear; }
From source file:com.mattfred.betterpickers.calendardatepicker.MonthView.java
/** * Sets up the text and style properties for painting. Override this if you want to use a different paint. *///from ww w . j a v a 2 s . 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(mDayTextColorEnabled); 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); mDisabledDaySquarePaint = new Paint(); mDisabledDaySquarePaint.setFakeBoldText(true); mDisabledDaySquarePaint.setAntiAlias(true); mDisabledDaySquarePaint.setColor(mDisabledDayColor); mDisabledDaySquarePaint.setTextAlign(Align.CENTER); mDisabledDaySquarePaint.setStyle(Style.FILL); mDisabledDaySquarePaint.setAlpha(DISABLED_DAY_SQUARE_ALPHA); mMonthDayLabelPaint = new Paint(); mMonthDayLabelPaint.setAntiAlias(true); mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE); mMonthDayLabelPaint.setColor(mDayTextColorEnabled); 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:com.philliphsu.bottomsheetpickers.date.MonthView.java
/** * Sets up the text and style properties for painting. Override this if you * want to use a different paint.//from w ww. ja v a2 s. 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(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(MONTH_DAY_LABEL_TEXT_SIZE); mMonthDayLabelPaint.setColor(mMonthDayLabelTextColor); 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:com.juick.android.TagsFragment.java
private void onTagClick(String tagg, int uid) { if (!multi) { parentActivity.onTagClick(tagg, uid); } else {//from ww w .ja v a 2 s . c om TextView tv = (TextView) myView.findViewById(R.id.tags); Spannable text = (Spannable) tv.getText(); TagOffsets tagOffsets1 = tagOffsets.get(tagg); if (!selectedTags.remove(tagg)) { if (selectedTags.size() == 5) { Toast.makeText(getActivity(), getString(R.string.TooManyTags), Toast.LENGTH_LONG).show(); return; } else { selectedTags.add(tagg); tagOffsets1.existingSpan = new StyleSpan(Typeface.BOLD); text.setSpan(tagOffsets1.existingSpan, tagOffsets1.offset, tagOffsets1.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } else { text.removeSpan(tagOffsets1.existingSpan); tagOffsets1.existingSpan = null; } final TextView selected = (TextView) myView.findViewById(R.id.selected); StringBuilder sb = new StringBuilder(); for (String selectedTag : selectedTags) { sb.append("*"); sb.append(selectedTag); sb.append(" "); } selected.setText(sb.toString().trim()); } }
From source file:com.nttec.everychan.ui.presentation.HtmlParser.java
public HtmlToSpannedConverter(String subject, String source, ThemeColors colors, HtmlParser.ImageGetter imageGetter, boolean openSpoilers, Parser parser) { mSource = source;// www .ja v a2s . c o m mSpannableStringBuilder = new SpannableStringBuilder(); if (!TextUtils.isEmpty(subject)) { mSpannableStringBuilder.append(subject); int len = mSpannableStringBuilder.length(); mSpannableStringBuilder.setSpan(new RelativeSizeSpan(1.25f), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mSpannableStringBuilder.setSpan(new StyleSpan(Typeface.BOLD), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); if (colors != null) { mSpannableStringBuilder.setSpan(new ForegroundColorSpan(colors.subjectForeground), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } mSpannableStringBuilder.append('\n'); mStartLength = mSpannableStringBuilder.length(); } mColors = colors; mOpenSpoilers = openSpoilers; mImageGetter = imageGetter; mReader = parser; }
From source file:com.facebook.FacebookButtonBase.java
private void parseTextAttributes(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { final int colorResources[] = { android.R.attr.textColor, }; final TypedArray colorAttrs = context.getTheme().obtainStyledAttributes(attrs, colorResources, defStyleAttr, defStyleRes);/*ww w . j a va 2s. c o m*/ try { setTextColor(colorAttrs.getColor(0, Color.WHITE)); } finally { colorAttrs.recycle(); } final int gravityResources[] = { android.R.attr.gravity, }; final TypedArray gravityAttrs = context.getTheme().obtainStyledAttributes(attrs, gravityResources, defStyleAttr, defStyleRes); try { setGravity(gravityAttrs.getInt(0, Gravity.CENTER)); } finally { gravityAttrs.recycle(); } final int attrsResources[] = { android.R.attr.textSize, android.R.attr.textStyle, android.R.attr.text, }; final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, attrsResources, defStyleAttr, defStyleRes); try { setTextSize(TypedValue.COMPLEX_UNIT_PX, a.getDimensionPixelSize(0, 0)); setTypeface(Typeface.defaultFromStyle(a.getInt(1, Typeface.BOLD))); setText(a.getString(2)); } finally { a.recycle(); } }