List of usage examples for android.graphics Typeface create
public static Typeface create(Typeface family, @Style int style)
From source file:com.koushikdutta.superuser.ActivityIntro.java
@Override public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment newFragment) { super.onSlideChanged(oldFragment, newFragment); if (newFragment != null && newFragment.getView() != null) { View parent = newFragment.getView(); TextView title = (TextView) parent.findViewById(R.id.title); if (title != null) { if (!(newFragment instanceof FragmentIntro)) title.setTextColor(0xffeaeaea); title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25); if (Build.VERSION.SDK_INT > 15) title.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL)); }// w w w.ja v a 2 s . c o m TextView desc = (TextView) parent.findViewById(R.id.description); if (desc != null) { desc.setTextColor(0xffe9e9e9); desc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15.5f); desc.setLineSpacing(1f, 1); //if (Build.VERSION.SDK_INT > 15) desc.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL)); } } }
From source file:com.sachinshinde.theweatherapp.utils.LUtils.java
public void setMediumTypeface(TextView textView) { if (hasL()) { if (sMediumTypeface == null) { sMediumTypeface = Typeface.create("sans-serif-medium", Typeface.NORMAL); }/*from w ww .j av a2 s. c om*/ textView.setTypeface(sMediumTypeface); } else { textView.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); } }
From source file:ru.tinkoff.acquiring.sdk.views.KeyView.java
private void init(final AttributeSet attrs) { setClickable(true);//from ww w. j a va2 s . c o m contentPaint = new Paint(); contentPaint.setTextSize(dpToPx(KEY_DEFAULT_TEXT_SIZE_DP)); contentPaint.setAntiAlias(true); contentPaint.setColor(ContextCompat.getColor(getContext(), R.color.acq_colorKeyText)); contentPaint.setTypeface(Typeface.create(DEFAULT_FONT_FAMILY, Typeface.NORMAL)); circlePaint = new Paint(); circlePaint.setColor(ContextCompat.getColor(getContext(), R.color.acq_colorKeyCircle)); applyAttrs(attrs); }
From source file:com.odoo.base.login_signup.SyncWizard.java
private void generateLayout() { LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.layoutLoginConfig); SyncWizardValues syncValues = new SyncWizardValues(); List<SyncValue> syncValuesList = syncValues.syncValues(); if (syncValuesList.size() == 0) { getActivity().finish();/*from ww w . j a v a 2s . c o m*/ getActivity().startActivity(getActivity().getIntent()); } checkbox = new CheckBox[syncValuesList.size()]; rdoGroups = new RadioGroup[syncValuesList.size()]; TextView[] txvTitles = new TextView[syncValuesList.size()]; int i = 0; int id = 1; Typeface tf_light = Typeface.create("sans-serif-light", 0); Typeface tf_bold = Typeface.create("sans-serif-condensed", 0); for (SyncValue value : syncValuesList) { if (!value.getIsGroup()) { if (value.getType() == SyncValue.Type.CHECKBOX) { checkbox[i] = new CheckBox(scope.context()); checkbox[i].setId(id); checkbox[i].setText(value.getTitle()); checkbox[i].setTypeface(tf_light); layout.addView(checkbox[i]); } else { rdoGroups[i] = new RadioGroup(scope.context()); rdoGroups[i].setId(i + 50); RadioButton[] rdoButtons = new RadioButton[value.getRadioGroups().size()]; int mId = 1; int j = 0; for (SyncValue rdoVal : value.getRadioGroups()) { rdoButtons[j] = new RadioButton(scope.context()); rdoButtons[j].setId(mId); rdoButtons[j].setText(rdoVal.getTitle()); rdoButtons[j].setTypeface(tf_light); rdoGroups[i].addView(rdoButtons[j]); mId++; j++; } layout.addView(rdoGroups[i]); } authorities.put(id + "", value.getAuthority()); i++; id++; } else { txvTitles[i] = new TextView(scope.context()); txvTitles[i].setId(id); txvTitles[i].setText(value.getTitle()); txvTitles[i].setAllCaps(true); txvTitles[i].setPadding(0, 5, 0, 3); txvTitles[i].setTypeface(tf_bold); layout.addView(txvTitles[i]); View lineView = new View(scope.context()); lineView.setBackgroundColor(Color.parseColor("#BEBEBE")); lineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1)); layout.addView(lineView); } } }
From source file:com.fastbootmobile.encore.app.fragments.NavigationDrawerFragment.java
public NavigationDrawerFragment() { sUnselectedTypeface = Typeface.create("sans-serif", 0); sSelectedTypeface = Typeface.create("sans-serif", Typeface.BOLD); }
From source file:de.treichels.hott.ui.android.html.AndroidCurveImageGenerator.java
private Bitmap getBitmap(final Curve curve, final float scale, final boolean description) { final boolean pitchCurve = curve.getPoint()[0].getPosition() == 0; final float scale1 = scale * 0.75f; // smaller images on the android // platform//w w w . j a v a 2 s. c o m final Bitmap image = Bitmap.createBitmap((int) (10 + 200 * scale1), (int) (10 + 250 * scale1), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(image); final Paint backgroundPaint = new Paint(); backgroundPaint.setColor(Color.WHITE); backgroundPaint.setStyle(Style.FILL); final Paint forgroundPaint = new Paint(); forgroundPaint.setColor(Color.BLACK); forgroundPaint.setStyle(Style.STROKE); forgroundPaint.setStrokeWidth(1.0f); forgroundPaint.setStrokeCap(Cap.BUTT); forgroundPaint.setStrokeJoin(Join.ROUND); forgroundPaint.setStrokeMiter(0.0f); final Paint curvePaint = new Paint(forgroundPaint); curvePaint.setFlags(Paint.ANTI_ALIAS_FLAG); curvePaint.setStrokeWidth(2.0f); final Paint pointPaint = new Paint(curvePaint); pointPaint.setStrokeWidth(5.0f); pointPaint.setStyle(Style.FILL_AND_STROKE); final Paint helpLinePaint = new Paint(forgroundPaint); helpLinePaint.setColor(Color.GRAY); helpLinePaint.setPathEffect(new DashPathEffect(new float[] { 5.0f, 5.0f }, 2.5f)); final Paint textPaint = new Paint(forgroundPaint); textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)); textPaint.setTextSize(12.0f); textPaint.setTextAlign(Align.CENTER); textPaint.setStyle(Style.FILL); canvas.drawRect(0, 0, 10 + 200 * scale1, 10 + 250 * scale1, backgroundPaint); canvas.drawRect(5, 5, 5 + 200 * scale1, 5 + 250 * scale1, forgroundPaint); canvas.drawLine(5, 5 + 25 * scale1, 5 + 200 * scale1, 5 + 25 * scale1, helpLinePaint); canvas.drawLine(5, 5 + 225 * scale1, 5 + 200 * scale1, 5 + 225 * scale1, helpLinePaint); if (!pitchCurve) { canvas.drawLine(5, 5 + 125 * scale1, 5 + 200 * scale1, 5 + 125 * scale1, helpLinePaint); canvas.drawLine(5 + 100 * scale1, 5, 5 + 100 * scale1, 5 + 250 * scale1, helpLinePaint); } if (curve.getPoint() != null) { int numPoints = 0; for (final CurvePoint p : curve.getPoint()) { if (p.isEnabled()) { numPoints++; } } final double[] xVals = new double[numPoints]; final double[] yVals = new double[numPoints]; int i = 0; for (final CurvePoint p : curve.getPoint()) { if (p.isEnabled()) { if (i == 0) { xVals[i] = pitchCurve ? 0 : -100; } else if (i == numPoints - 1) { xVals[i] = 100; } else { xVals[i] = p.getPosition(); } yVals[i] = p.getValue(); if (description) { float x0; float y0; if (pitchCurve) { x0 = (float) (5 + xVals[i] * 2 * scale1); y0 = (float) (5 + (225 - yVals[i] * 2) * scale1); } else { x0 = (float) (5 + (100 + xVals[i]) * scale1); y0 = (float) (5 + (125 - yVals[i]) * scale1); } canvas.drawPoint(x0, y0, pointPaint); if (y0 < 5 + 125 * scale1) { canvas.drawRect(x0 - 4, y0 + 5, x0 + 3, y0 + 18, backgroundPaint); canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 + 16, textPaint); } else { canvas.drawRect(x0 - 4, y0 - 5, x0 + 3, y0 - 18, backgroundPaint); canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 - 7, textPaint); } } i++; } } if (numPoints > 2 && curve.isSmoothing()) { final SplineInterpolator s = new SplineInterpolator(); final PolynomialSplineFunction function = s.interpolate(xVals, yVals); float x0 = 5; float y0; if (pitchCurve) { y0 = (float) (5 + (225 - yVals[0] * 2) * scale1); } else { y0 = (float) (5 + (125 - yVals[0]) * scale1); } while (x0 < 4 + 200 * scale1) { final float x1 = x0 + 1; float y1; if (pitchCurve) { y1 = (float) (5 + (225 - function.value((x1 - 5) / scale1 / 2) * 2) * scale1); } else { y1 = (float) (5 + (125 - function.value((x1 - 5) / scale1 - 100)) * scale1); } canvas.drawLine(x0, y0, x1, y1, curvePaint); x0 = x1; y0 = y1; } } else { for (i = 0; i < numPoints - 1; i++) { float x0, y0, x1, y1; if (pitchCurve) { x0 = (float) (5 + xVals[i] * 2 * scale1); y0 = (float) (5 + (225 - yVals[i] * 2) * scale1); x1 = (float) (5 + xVals[i + 1] * 2 * scale1); y1 = (float) (5 + (225 - yVals[i + 1] * 2) * scale1); } else { x0 = (float) (5 + (100 + xVals[i]) * scale1); y0 = (float) (5 + (125 - yVals[i]) * scale1); x1 = (float) (5 + (100 + xVals[i + 1]) * scale1); y1 = (float) (5 + (125 - yVals[i + 1]) * scale1); } canvas.drawLine(x0, y0, x1, y1, curvePaint); } } } return image; }
From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTextsView.java
public void initialize(Resources res, String[] texts, String[] innerTexts, boolean is24HourMode, boolean disappearsOut) { if (mIsInitialized) { Log.e(TAG, "This RadialTextsView may only be initialized once."); return;//from ww w . j ava2 s . c om } // Set up the paint. mPaint.setColor(res.getColor(R.color.numbers_text_color)); String typefaceFamily = res.getString(R.string.radial_numbers_typeface); mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL); String typefaceFamilyRegular = res.getString(R.string.sans_serif); mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL); mPaint.setAntiAlias(true); mPaint.setTextAlign(Align.CENTER); mTexts = texts; mInnerTexts = innerTexts; mIs24HourMode = is24HourMode; mHasInnerCircle = (innerTexts != null); // Calculate the radius for the main circle. if (is24HourMode) { mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier_24HourMode)); } else { mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier)); } // Initialize the widths and heights of the grid, and calculate the values for the numbers. mTextGridHeights = new float[7]; mTextGridWidths = new float[7]; if (mHasInnerCircle) { mNumbersRadiusMultiplier = Float.parseFloat(res.getString(R.string.numbers_radius_multiplier_outer)); mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.text_size_multiplier_outer)); mInnerNumbersRadiusMultiplier = Float .parseFloat(res.getString(R.string.numbers_radius_multiplier_inner)); mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.text_size_multiplier_inner)); mInnerTextGridHeights = new float[7]; mInnerTextGridWidths = new float[7]; } else { mNumbersRadiusMultiplier = Float.parseFloat(res.getString(R.string.numbers_radius_multiplier_normal)); mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.text_size_multiplier_normal)); } mAnimationRadiusMultiplier = 1; mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1)); mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1)); mInvalidateUpdateListener = new InvalidateUpdateListener(); mTextGridValuesDirty = true; mIsInitialized = true; }
From source file:com.chauffeurprive.kronos.time.AmPmCirclesView.java
public void initialize(Context context, TimePickerController controller, int amOrPm) { if (mIsInitialized) { Log.e(TAG, "AmPmCirclesView may only be initialized once."); return;// w w w . ja v a2s . c o m } Resources res = context.getResources(); mUnselectedColor = ContextCompat.getColor(context, controller.getCircleBackgroundColor()); mAmPmTextColor = ContextCompat.getColor(context, controller.getTextColor()); mAmPmDisabledTextColor = ContextCompat.getColor(context, controller.getDisabledTextColor()); mSelectedAlpha = SELECTED_ALPHA; mSelectedColor = ContextCompat.getColor(context, controller.getAccentColor()); mTouchedColor = ContextCompat.getColor(context, controller.getDisabledTextColor()); mAmPmSelectedTextColor = ContextCompat.getColor(context, controller.getSelectedTextColor()); String typefaceFamily = res.getString(R.string.mdtp_sans_serif); Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL); mPaint.setTypeface(tf); mPaint.setAntiAlias(true); mPaint.setTextAlign(Align.CENTER); mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier)); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mAmDisabled = controller.isAmDisabled(); mPmDisabled = controller.isPmDisabled(); setAmOrPm(amOrPm); mAmOrPmPressed = -1; mIsInitialized = true; }
From source file:com.jauker.badgeview.example.ViewsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.fragment_views, null); View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault); backgroundDefaultBadge = new BadgeView(getActivity()); backgroundDefaultBadge.setBadgeCount(42); backgroundDefaultBadge.setTargetView(backgroundDefaultView); View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable); backgroundDrawableBadge = new BadgeView(getActivity()); backgroundDrawableBadge.setBadgeCount(88); backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue); backgroundDrawableBadge.setTargetView(backgroundDrawableView); View backgroundShapeView = layout.findViewById(R.id.backgroundShape); backgroundShapeBadge = new BadgeView(getActivity()); backgroundShapeBadge.setBadgeCount(47); backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef")); backgroundShapeBadge.setTargetView(backgroundShapeView); View counterView = layout.findViewById(R.id.counter); counterView.setOnClickListener(this); counterBadge = new BadgeView(getActivity()); counterBadge.setBadgeCount(-2);/*from w w w . j a v a 2 s .c o m*/ counterBadge.setTargetView(counterView); View gravityView = layout.findViewById(R.id.gravity); gravityView.setOnClickListener(this); gravityBadge = new BadgeView(getActivity()); gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM); gravityBadge.setBadgeCount(4); gravityBadge.setTargetView(gravityView); View textStyleView = layout.findViewById(R.id.textStyle); textStyleView.setOnClickListener(this); textStyleBadge = new BadgeView(getActivity()); textStyleBadge.setBadgeCount(18); textStyleBadge.setTargetView(textStyleView); textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC)); textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN); View visibilityView = layout.findViewById(R.id.visibility); visibilityView.setOnClickListener(this); visibilityBadgeView = new BadgeView(getActivity()); visibilityBadgeView.setBadgeCount(1); visibilityBadgeView.setTargetView(visibilityView); return layout; }
From source file:com.ayoview.sample.textview.badge.ViewsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.badge_fragment_views, null); View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault); backgroundDefaultBadge = new BadgeView(getActivity()); backgroundDefaultBadge.setBadgeCount(42); backgroundDefaultBadge.setTargetView(backgroundDefaultView); View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable); backgroundDrawableBadge = new BadgeView(getActivity()); backgroundDrawableBadge.setBadgeCount(88); backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue); backgroundDrawableBadge.setTargetView(backgroundDrawableView); View backgroundShapeView = layout.findViewById(R.id.backgroundShape); backgroundShapeBadge = new BadgeView(getActivity()); backgroundShapeBadge.setBadgeCount(47); backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef")); backgroundShapeBadge.setTargetView(backgroundShapeView); View counterView = layout.findViewById(R.id.counter); counterView.setOnClickListener(this); counterBadge = new BadgeView(getActivity()); counterBadge.setBadgeCount(-2);/*from ww w . ja va 2 s .c o m*/ counterBadge.setTargetView(counterView); View gravityView = layout.findViewById(R.id.gravity); gravityView.setOnClickListener(this); gravityBadge = new BadgeView(getActivity()); gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM); gravityBadge.setBadgeCount(4); gravityBadge.setTargetView(gravityView); View textStyleView = layout.findViewById(R.id.textStyle); textStyleView.setOnClickListener(this); textStyleBadge = new BadgeView(getActivity()); textStyleBadge.setBadgeCount(18); textStyleBadge.setTargetView(textStyleView); textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC)); textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN); View visibilityView = layout.findViewById(R.id.visibility); visibilityView.setOnClickListener(this); visibilityBadgeView = new BadgeView(getActivity()); visibilityBadgeView.setBadgeCount(1); visibilityBadgeView.setTargetView(visibilityView); return layout; }