List of usage examples for android.graphics Typeface DEFAULT_BOLD
Typeface DEFAULT_BOLD
To view the source code for android.graphics Typeface DEFAULT_BOLD.
Click Source Link
From source file:com.crazy.toutiaonews.SlidingTabLayout.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 a v a 2 s . co m*/ */ protected TextView createDefaultTabView(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); // Holo ?? // 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.cssweb.android.view.FinanceMini.java
public void drawPrice(Canvas canvas) { //canvas.restore(); Paint paint = this.mPaint; paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true);// w ww. jav a 2 s . c o 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, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); int syjd = jo.getInt("syjd"); switch (syjd) { case 1: canvas.drawText("()", x, y, paint); break; case 2: canvas.drawText("()", x, y, paint); break; case 3: canvas.drawText("()", x, y, paint); break; case 4: canvas.drawText("()", x, y, paint); break; default: canvas.drawText("", x, y, paint); break; } if (jo.getDouble("wb") < 0) paint.setColor(GlobalColor.colorPriceDown); else if (jo.getDouble("wb") > 0) paint.setColor(GlobalColor.colorpriceUp); else paint.setColor(GlobalColor.colorPriceEqual); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY * 5); if (jo.getInt("tp") == 1) canvas.drawText("", x - tips, y, paint); else canvas.drawText(Utils.dataFormation(jo.getDouble("wb") * 100, 1) + "%", x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getInt("cjsl"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorpriceUp); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("hs") * 100, 1) + "%", x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("jz"), 1), x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("mgsy"), 2), x - tips, y, paint); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.translate(0, -DY * 5); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); if (NameRule.isBond(type)) canvas.drawText("", x, y, paint); else canvas.drawText("PE()", x, y, paint); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY * 5); if (jo.getDouble("wc") < 0) { paint.setColor(GlobalColor.colorPriceDown); canvas.drawText("-" + Utils.getAmountFormat(Math.abs(jo.getDouble("wc")), true), x - tips, y, paint); } else if (jo.getDouble("wc") > 0) { paint.setColor(GlobalColor.colorpriceUp); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), true), x - tips, y, paint); } else { paint.setColor(GlobalColor.colorPriceEqual); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), false), x - tips, y, paint); } paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1, jo.getInt("tp")), x - tips, y, paint); paint.setColor(GlobalColor.colorPriceDown); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("gb"), true), x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("ltsl") * 100, true), x - tips, y, paint); canvas.translate(0, DY); if (NameRule.isBond(type)) { canvas.drawText(Utils.dataFormation(jo.getDouble("fullprice"), 1), x - tips, y, paint); } else { canvas.drawText(Utils.dataFormation(jo.getDouble("sy"), 1), x - tips, y, paint); } } catch (JSONException e) { Log.e(TAG, e.toString()); } } }
From source file:com.leo.tablayout.SlidingTabLayout.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)}./*from w ww .j a v a2 s .c o m*/ */ protected TextView createDefaultTabView(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); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // TypedValue outValue = new TypedValue(); // getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, // outValue, true); // textView.setBackgroundResource(outValue.resourceId); // textView.setAllCaps(true); if (colorStateList != null) { textView.setTextColor(colorStateList); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.anysoftkeyboard.keyboards.views.CandidateView.java
/** * If the canvas is null, then only touch calculations are performed to pick * the target candidate.//from w w w . j a v a 2 s.c om */ @Override protected void onDraw(Canvas canvas) { if (canvas != null) { super.onDraw(canvas); } mTotalWidth = 0; final int height = getHeight(); if (mBgPadding == null) { mBgPadding = new Rect(0, 0, 0, 0); if (getBackground() != null) { getBackground().getPadding(mBgPadding); } mDivider.setBounds(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight()); } final int dividerYOffset = (height - mDivider.getMinimumHeight()) / 2; final int count = mSuggestions.size(); final Rect bgPadding = mBgPadding; final Paint paint = mPaint; final int touchX = mTouchX; final int scrollX = getScrollX(); final boolean scrolled = mScrolled; final boolean typedWordValid = mTypedWordValid; int x = 0; for (int i = 0; i < count; i++) { CharSequence suggestion = mSuggestions.get(i); if (suggestion == null) continue; final int wordLength = suggestion.length(); paint.setColor(mColorNormal); if (mHaveMinimalSuggestion && ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) { paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setColor(mColorRecommended); // existsAutoCompletion = true; } else if (i != 0 || (wordLength == 1 && count > 1)) { // HACK: even if i == 0, we use mColorOther when this // suggestion's length is 1 and // there are multiple suggestions, such as the default // punctuation list. paint.setColor(mColorOther); } // now that we set the typeFace, we can measure int wordWidth; if ((wordWidth = mWordWidth[i]) == 0) { float textWidth = paint.measureText(suggestion, 0, wordLength); // wordWidth = Math.max(0, (int) textWidth + X_GAP * 2); wordWidth = (int) (textWidth + mHorizontalGap * 2); mWordWidth[i] = wordWidth; } mWordX[i] = x; if (touchX != OUT_OF_BOUNDS_X_CORD && !scrolled && touchX + scrollX >= x && touchX + scrollX < x + wordWidth) { if (canvas != null && !mShowingAddToDictionary) { canvas.translate(x, 0); mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height); mSelectionHighlight.draw(canvas); canvas.translate(-x, 0); } mSelectedString = suggestion; mSelectedIndex = i; } if (canvas != null) { // (+)This is the trick to get RTL/LTR text correct if (AnyApplication.getConfig().workaround_alwaysUseDrawText()) { final int y = (int) (height + paint.getTextSize() - paint.descent()) / 2; canvas.drawText(suggestion, 0, wordLength, x + wordWidth / 2, y, paint); } else { final int y = (int) (height - paint.getTextSize() + paint.descent()) / 2; // no matter what: StaticLayout float textX = x + (wordWidth / 2) - mHorizontalGap; float textY = y - bgPadding.bottom - bgPadding.top; canvas.translate(textX, textY); mTextPaint.setTypeface(paint.getTypeface()); mTextPaint.setColor(paint.getColor()); StaticLayout suggestionText = new StaticLayout(suggestion, mTextPaint, wordWidth, Alignment.ALIGN_CENTER, 1.0f, 0.0f, false); suggestionText.draw(canvas); canvas.translate(-textX, -textY); } // (-) paint.setColor(mColorOther); canvas.translate(x + wordWidth, 0); // Draw a divider unless it's after the hint //or the last suggested word if (count > 1 && (!mShowingAddToDictionary) && i != (count - 1)) { canvas.translate(0, dividerYOffset); mDivider.draw(canvas); canvas.translate(0, -dividerYOffset); } canvas.translate(-x - wordWidth, 0); } paint.setTypeface(Typeface.DEFAULT); x += wordWidth; } mTotalWidth = x; if (mTargetScrollX != scrollX) { scrollToTarget(); } }
From source file:com.owncloud.android.ui.dialog.SortingOrderDialogFragment.java
/** * Sets the text color and tint the icon of given text view and image button. * * @param imageButton the image button, the icon to be tinted * @param textView the text view, the text color to be set *///from w w w. j a v a 2 s. c om private void colorActiveSortingIconAndText(ImageButton imageButton, TextView textView) { int color = getResources().getColor(R.color.color_accent); DisplayUtils.colorImageButton(imageButton, color); textView.setTextColor(color); textView.setTypeface(Typeface.DEFAULT_BOLD); }
From source file:com.orange.ocara.ui.view.PagerSlidingTabStrip.java
private void updateTabStates(int selectedPosition) { for (int i = 0; i < tabCount; i++) { boolean isSelected = (i == selectedPosition); View v = tabsContainer.getChildAt(i); TextView tab = (TextView) v;/* www. j a v a 2 s.c om*/ if (isSelected == true) { tab.setTypeface(Typeface.DEFAULT_BOLD); } else { tab.setTypeface(Typeface.DEFAULT); } } }
From source file:at.linuxtage.companion.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView;/*from w w w.j av a2 s . c o m*/ TextView tabTitleView; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { setSelectedCompat(tabView, true); } } }
From source file:org.toulibre.capitoledulibre.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView;//from w w w. j a v a2s .c o m TextView tabTitleView; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { setSelectedCompat(tabView, true); } } }
From source file:com.android.widget.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from ww w. ja va 2 s.c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } else { tabView = createDefaultTabView(getContext()); tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i).toString().toUpperCase()); tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); tabTitleView.setTextColor(getResources() .getColor(Util.getResourceFromAttribute(getContext(), R.attr.font_actionbar_selected))); } } }
From source file:com.cssweb.android.view.KlineMini.java
public void onDraw(Canvas canvas) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(1);/* w w w . j av a 2 s . c o m*/ tPaint = new Paint(); tPaint.setStyle(Paint.Style.STROKE); tPaint.setTypeface(Typeface.DEFAULT_BOLD); tPaint.setAntiAlias(true); tPaint.setTextSize(dTextSize); // tips = (int) tPaint.measureText("0"); try { if (actualDataLen == 0) { return; } if (zs) axisLabelWidth = (int) Math.max(tPaint.measureText("99999.99"), tPaint.measureText("11000")); else axisLabelWidth = (int) tPaint.measureText("11000"); klineWidth = width - axisLabelWidth; //?spaceWidth??? visualKLineCount = (int) ((klineWidth - spaceWidth) / (spaceWidth + shapeWidth)); if (isSingleMoved == false && isTrackStatus == false) { if (actualDataLen > visualKLineCount) { actualPos = actualDataLen - visualKLineCount; count = visualKLineCount; } else { actualPos = 0; count = actualDataLen; } } calcMaxMin(actualPos); if (!isTrackStatus) { moveQuote(actualDataLen - 1); } else { if (trackLineV == 0) { trackLineV = (int) (visualPos * (spaceWidth + shapeWidth) - shapeWidth / 2); isTrackNumber = actualPos + visualPos - 1; } if (isTrackNumber < 0) { isTrackNumber = 0; } else if (isTrackNumber > actualDataLen - 1) { isTrackNumber = actualDataLen - 1; } paint.setColor(GlobalColor.clrGrayLine); canvas.drawLine(klineX + trackLineV, axisLabelHeight, klineX + trackLineV, height - axisLabelHeight, paint); moveQuote(isTrackNumber); drawQuoteWin(canvas, quoteData, isTrackNumber); } // axisLabelHeight = Font.getFontHeight(dTextSize); klineX = axisLabelWidth; klineY = axisLabelHeight; klineHeight = height - axisLabelHeight * 2; axisX = klineX; // tPaint.setTextAlign(Paint.Align.LEFT); tPaint.setColor(GlobalColor.colorM5); canvas.drawText(lblIndicatorName, (float) (klineX + shapeWidth), axisLabelHeight - 5, tPaint); float size = tPaint.measureText(lblIndicatorName) + tips; tPaint.setColor(GlobalColor.colorM10); canvas.drawText(lblIndicatorT1, (float) (klineX + shapeWidth + size), axisLabelHeight - 5, tPaint); size += tPaint.measureText(lblIndicatorT1) + tips; if (size <= (klineWidth - tPaint.measureText(lblIndicatorT2))) { //tPaint.setColor(GlobalColor.colorM20); tPaint.setARGB(255, 255, 0, 255); canvas.drawText(lblIndicatorT2, (float) (klineX + shapeWidth + size), axisLabelHeight - 5, tPaint); } size += tPaint.measureText(lblIndicatorT2) + tips; if (size <= (klineWidth - tPaint.measureText(lblIndicatorT3))) { tPaint.setColor(GlobalColor.colorM60); canvas.drawText(lblIndicatorT3, (float) (klineX + shapeWidth + size), axisLabelHeight - 5, tPaint); } //??? rowHeight = klineHeight / rowNum; scale = klineHeight / (highPrice - lowPrice); double ratio = (highPrice - lowPrice) / rowNum; paint.setColor(GlobalColor.clrLine); tPaint.setColor(GlobalColor.colorTicklabel); tPaint.setTextAlign(Paint.Align.RIGHT); for (int i = 0; i <= rowNum; i++) { if (i == rowNum || i == 0) { canvas.drawLine(klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } else { Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } if (i != rowNum && isTrackStatus == false) { double AxisLabelPrice = highPrice - ratio * i; String AxisLabelPriceText; if (zs) { AxisLabelPriceText = Utils.dataFormation(Math.round(AxisLabelPrice), 0); } else { AxisLabelPriceText = Utils.dataFormation(AxisLabelPrice, stockdigit); } canvas.drawText(AxisLabelPriceText, klineX - tips / 4, klineY + rowHeight * i + axisLabelHeight / 2, tPaint); } } // if (quoteData != null) { //axisX = 0; for (int i = actualPos; i < (actualPos + count); i++) { if (i == 0) drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(2), quoteData.getJSONArray("K").getJSONArray(i).getDouble(3), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4)); else drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(2), quoteData.getJSONArray("K").getJSONArray(i).getDouble(3), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i - 1).getDouble(4)); } if (mainIndicatorType.toUpperCase().equals("MA")) drawMA(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); drawTimeAix(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume, actualDataLen); } //????? paint.setColor(GlobalColor.clrLine); canvas.drawLine(klineX, 0, width, 0, paint); canvas.drawLine(klineX, 0, klineX, height - axisLabelHeight, paint); canvas.drawLine(width, 0, width, height - axisLabelHeight, paint); } catch (JSONException e) { e.printStackTrace(); } }