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:com.cssweb.android.view.TrendView.java

private void drawChart(Canvas canvas) throws JSONException {
    Log.i("@@@@@@@@@draw tick@@@@@@@@@@", quoteArray + ">>>>>>>>>");
    //Log.i("@@@@@@@@@@@@@@@@@@@", quoteArray.length()+">>>>>>>>>");
    if (quoteArray == null || quoteArray.isNull(0))
        return;//from ww  w.j a v  a2s . c  om

    canvas.drawColor(GlobalColor.clearSCREEN);

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);

    mpaint = new Paint();
    mpaint.setTypeface(Typeface.DEFAULT_BOLD);
    mpaint.setAntiAlias(true);
    mpaint.setTextAlign(Paint.Align.LEFT);
    mpaint.setStyle(Paint.Style.STROKE);
    mpaint.setTextSize(dTextSize);

    /**
     * ?
     */
    closeLeft = Utils.dataFormation(high, stockdigit);
    closeRight = "00.00%";
    LSpace = (int) (Math.max(mpaint.measureText(closeLeft),
            mpaint.measureText(String.valueOf(Math.round(highvolume)))));
    //???
    //RSpace = (int)(paint.measureText(closeRight) + 10);
    RSpace = 0;

    axisLabelHeight = Font.getFontHeight(dTextSize);

    graphicsQuoteWidth = width - LSpace - RSpace;
    SPACE = graphicsQuoteWidth / MINUTES;
    topTitleHeight = axisLabelHeight;
    graphicsQuoteHeight = height - axisLabelHeight - topTitleHeight;
    price_row_num = 2;//(int)graphicsQuoteHeight/3/25;
    volume_row_num = price_row_num;
    price_row_height = graphicsQuoteHeight / price_row_num / 3;
    volume_row_height = price_row_height;

    calc_zf();

    title1 = ":";
    title7 = ":";
    title8 = quoteArray.getJSONArray(isTrackNumber).getString(3);
    title2 = Utils.dataFormation(quoteArray.getJSONArray(isTrackNumber).getDouble(0), stockdigit);

    mpaint.setColor(GlobalColor.colorLabelName);

    canvas.drawText(title7 + title8.substring(11, 16), LSpace, axisLabelHeight - 5, mpaint);
    canvas.drawText(title1, LSpace + mpaint.measureText(":00:0000"), axisLabelHeight - 5, mpaint);
    if (quoteArray.getJSONArray(isTrackNumber).getDouble(0) == 0) {
        mpaint.setColor(GlobalColor.colorPriceEqual);
    } else if (quoteArray.getJSONArray(isTrackNumber).getDouble(0) > close) {
        mpaint.setColor(GlobalColor.colorpriceUp);
    } else if (quoteArray.getJSONArray(isTrackNumber).getDouble(0) < close) {
        mpaint.setColor(GlobalColor.colorPriceDown);
    } else {
        mpaint.setColor(GlobalColor.colorPriceEqual);
    }
    canvas.drawText(title2, LSpace + mpaint.measureText(":00:0000:"), axisLabelHeight - 5, mpaint);

    if (!this.isZs()) {
        if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)
                || "hk".equals(exchange)) {
        } else {
            mpaint.setColor(GlobalColor.colorLabelName);
            title9 = "?:";
            canvas.drawText(title9, LSpace + mpaint.measureText(":00:000000:" + title2),
                    axisLabelHeight - 5, mpaint);
            double avePrice = 0;
            double cjje = quoteArray.getJSONArray(isTrackNumber).getDouble(2);
            int scaleCount = 1;
            scaleCount = Utils.getCoefficient(exchange, stockcode);
            double cjsl = quoteArray.getJSONArray(isTrackNumber).getDouble(1) * scaleCount;
            if (cjsl > 0) {
                avePrice = cjje / cjsl;
            } else {
                avePrice = jrkp;
            }
            if (avePrice == 0) {
                mpaint.setColor(GlobalColor.colorPriceEqual);
            } else if (avePrice > close) {
                mpaint.setColor(GlobalColor.colorpriceUp);
            } else if (avePrice < close) {
                mpaint.setColor(GlobalColor.colorPriceDown);
            } else {
                mpaint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.drawText(Utils.dataFormation(avePrice, stockdigit),
                    LSpace + mpaint.measureText(":00:000000:" + title2 + "?:"),
                    axisLabelHeight - 5, mpaint);
        }
    }

    if (isZs()) {
        if (close == 0)
            close = 1000;
    } else {
        if (close == 0)
            close = 1;
    }

    low = Math.min(low, close);
    //upPrice = close * (1+max_zf);
    //downPrice = close * (1-max_zf);

    paint.setColor(GlobalColor.clrLine);
    canvas.drawLine(LSpace + graphicsQuoteWidth, topTitleHeight, LSpace + graphicsQuoteWidth,
            graphicsQuoteHeight + topTitleHeight, paint);

    // 
    upQuoteX = LSpace;
    upQuoteY = topTitleHeight;
    upQuoteWidth = (int) graphicsQuoteWidth;
    upQuoteHeight = price_row_num * price_row_height;
    for (int i = 0; i < price_row_num; i++) {
        if (i == 0) {
            canvas.drawLine(upQuoteX, upQuoteY + price_row_height * i, upQuoteX + upQuoteWidth,
                    upQuoteY + price_row_height * i, paint);
        } else
            Graphics.drawDashline(canvas, upQuoteX, upQuoteY + price_row_height * i, upQuoteX + upQuoteWidth,
                    upQuoteY + price_row_height * i, paint);
    }

    for (int i = 0; i < DIVIDE_COUNT; i++) {
        if (i == 0) {
            canvas.drawLine(upQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, upQuoteY,
                    upQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, upQuoteY + upQuoteHeight, paint);
        } else
            Graphics.drawDashline(canvas, upQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, upQuoteY,
                    upQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, upQuoteY + upQuoteHeight, paint);
    }
    //scale = close * max_zf / price_row_num;
    scale = Arith.div(close * max_zf, price_row_num, stockdigit + 1);

    mpaint.setTextAlign(Paint.Align.RIGHT);
    mpaint.setColor(GlobalColor.colorPriceEqual);
    canvas.drawText(Utils.dataFormation(close, stockdigit), upQuoteX,
            upQuoteY + upQuoteHeight + axisLabelHeight / 2, mpaint);

    mpaint.setColor(GlobalColor.colorpriceUp);
    for (int i = 1; i <= price_row_num; i++) {
        AxisLabelPrice = close + scale * i;
        canvas.drawText(Utils.dataFormation(AxisLabelPrice, stockdigit), upQuoteX,
                upQuoteY + upQuoteHeight - price_row_height * i + axisLabelHeight / 2, mpaint);
    }

    // 
    downQuoteX = LSpace;
    downQuoteY = topTitleHeight + upQuoteHeight;
    downQuoteWidth = (int) graphicsQuoteWidth;

    downQuoteHeight = upQuoteHeight;

    paint.setColor(GlobalColor.clrLine);
    for (int i = 0; i < price_row_num; i++) {
        if (i == 0) {
            canvas.drawLine(downQuoteX, downQuoteY + price_row_height * i, downQuoteX + downQuoteWidth,
                    downQuoteY + price_row_height * i, paint);
        } else
            Graphics.drawDashline(canvas, downQuoteX, downQuoteY + price_row_height * i,
                    downQuoteX + downQuoteWidth, downQuoteY + price_row_height * i, paint);
    }

    for (int i = 0; i < DIVIDE_COUNT; i++) {
        if (i == 0) {
            canvas.drawLine(downQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, downQuoteY,
                    downQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, downQuoteY + downQuoteHeight + 1, paint);
        } else
            Graphics.drawDashline(canvas, downQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, downQuoteY,
                    downQuoteX + MINUTES / DIVIDE_COUNT * SPACE * i, downQuoteY + downQuoteHeight, paint);
    }

    mpaint.setColor(GlobalColor.colorPriceDown);
    for (int i = 1; i < price_row_num; i++) {
        AxisLabelPrice = close - scale * i;
        canvas.drawText(Utils.dataFormation(AxisLabelPrice, stockdigit), upQuoteX,
                upQuoteY + upQuoteHeight + price_row_height * i + axisLabelHeight / 2, mpaint);
    }

    //  
    // added by hujun for 20110511???
    if (actualDataLen > 0 && !this.isOpenFund()) {
        if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) {
            scale = upQuoteHeight / (close * max_zf);
            paint.setColor(GlobalColor.colorFZLine);
            int quotelen = quoteArray.length();
            double x1 = 0;
            double y1 = 0;
            double x2 = 0;
            double y2 = 0;
            double temp = 0;

            x1 = upQuoteX;
            double lastnewp = 0;
            double nownewp = 0;
            nownewp = quoteArray.getJSONArray(0).getDouble(0);
            if (nownewp == 0)
                nownewp = close;
            if (nownewp >= close) {
                temp = (nownewp - close) * scale;
                y1 = topTitleHeight + upQuoteHeight - temp;
            } else {
                temp = (close - nownewp) * scale;
                y1 = topTitleHeight + upQuoteHeight + temp;
            }
            lastnewp = nownewp;
            for (int i = 1; i < quotelen; i++) {
                x2 = upQuoteX + SPACE * i;
                nownewp = quoteArray.getJSONArray(i).getDouble(0);
                if (nownewp == 0)
                    nownewp = lastnewp;
                if (nownewp >= close) {
                    temp = (nownewp - close) * scale;
                    y2 = topTitleHeight + upQuoteHeight - temp;
                } else {
                    temp = (close - nownewp) * scale;
                    y2 = topTitleHeight + upQuoteHeight + temp;
                }
                lastnewp = nownewp;

                canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);

                x1 = x2;
                y1 = y2;
            } // end for

            paint.setColor(GlobalColor.colorFZAvePriceLine);
            x1 = upQuoteX;
            double cjje = quoteArray.getJSONArray(0).getDouble(0);
            double avePrice = cjje;
            double lastavg = 0;
            if (avePrice > high) {
                avePrice = high;
            }
            if (avePrice < low) {
                avePrice = low;
            }
            if (avePrice >= close) {
                temp = (avePrice - close) * scale;
                y1 = topTitleHeight + upQuoteHeight - temp;
            } else {
                temp = (close - avePrice) * scale;
                y1 = topTitleHeight + upQuoteHeight + temp;
            }
            lastavg = avePrice;
            double xl = quoteArray.getJSONArray(0).getDouble(1);
            double mathpjj = quoteArray.getJSONArray(0).getDouble(0) * xl;
            for (int i = 1; i < quotelen; i++) {
                x2 = upQuoteX + SPACE * i;
                mathpjj += quoteArray.getJSONArray(i).getDouble(0) * (quoteArray.getJSONArray(i).getDouble(1)
                        - quoteArray.getJSONArray(i - 1).getDouble(1));
                if (mathpjj == 0) {
                    if (lastavg == 0) {
                        avePrice = close;
                    } else {
                        avePrice = lastavg;
                    }
                } else {
                    avePrice = mathpjj / quoteArray.getJSONArray(i).getDouble(1);
                }
                lastavg = avePrice;
                if (avePrice > high) {
                    avePrice = high;
                }
                if (avePrice < low) {
                    avePrice = low;
                }
                if (avePrice >= close) {
                    temp = (avePrice - close) * scale;
                    y2 = topTitleHeight + upQuoteHeight - temp;
                } else {
                    temp = (close - avePrice) * scale;
                    y2 = topTitleHeight + upQuoteHeight + temp;
                }
                canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);

                x1 = x2;
                y1 = y2;
            } // end for
        } else {
            scale = upQuoteHeight / (close * max_zf);
            paint.setColor(GlobalColor.colorFZLine);
            int quotelen = quoteArray.length();
            double x1 = 0;
            double y1 = 0;
            double x2 = 0;
            double y2 = 0;
            double temp = 0;

            x1 = upQuoteX;
            double lastnewp = 0;
            double nownewp = 0;
            nownewp = quoteArray.getJSONArray(0).getDouble(0);
            if (nownewp == 0)
                nownewp = close;
            if (nownewp >= close) {
                temp = (nownewp - close) * scale;
                y1 = topTitleHeight + upQuoteHeight - temp;
            } else {
                temp = (close - nownewp) * scale;
                y1 = topTitleHeight + upQuoteHeight + temp;
            }
            lastnewp = nownewp;
            for (int i = 1; i < quotelen; i++) {
                x2 = upQuoteX + SPACE * i;
                nownewp = quoteArray.getJSONArray(i).getDouble(0);
                if (nownewp == 0)
                    nownewp = lastnewp;
                if (nownewp >= close) {
                    temp = (nownewp - close) * scale;
                    y2 = topTitleHeight + upQuoteHeight - temp;
                } else {
                    temp = (close - nownewp) * scale;
                    y2 = topTitleHeight + upQuoteHeight + temp;
                }
                lastnewp = nownewp;

                canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);

                x1 = x2;
                y1 = y2;
            } // end for

            if (this.isZs()) {
                // ?   ??
                if ("sz".equals(exchange) || "sh".equals(exchange)) {
                    if (("000001".equals(stockcode) || "399001".equals(stockcode))
                            && !quoteData.isNull("data2")) {
                        paint.setColor(GlobalColor.colorFZAvePriceLine);
                        x1 = upQuoteX;
                        double avePrice = quoteData.getJSONArray("data2").getJSONArray(0).getDouble(0);
                        if (avePrice > high) {
                            avePrice = high;
                        }
                        if (avePrice < low) {
                            avePrice = low;
                        }
                        if (avePrice >= close) {
                            temp = (avePrice - close) * scale;
                            y1 = topTitleHeight + upQuoteHeight - temp;
                        } else {
                            temp = (close - avePrice) * scale;
                            y1 = topTitleHeight + upQuoteHeight + temp;
                        }
                        int len = quoteData.getJSONArray("data2").length();
                        for (int i = 1; i < len; i++) {
                            if ("15:00".equals(quoteData.getJSONArray("data2").getJSONArray(i).getString(1)
                                    .substring(11, 16))) {

                            } else {
                                x2 = upQuoteX + SPACE * i;
                                avePrice = quoteData.getJSONArray("data2").getJSONArray(i).getDouble(0);
                                if (avePrice > high) {
                                    avePrice = high;
                                }
                                if (avePrice < low) {
                                    avePrice = low;
                                }
                                if (avePrice >= close) {
                                    temp = (avePrice - close) * scale;
                                    y2 = topTitleHeight + upQuoteHeight - temp;
                                } else {
                                    temp = (close - avePrice) * scale;
                                    y2 = topTitleHeight + upQuoteHeight + temp;
                                }
                                canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);

                                x1 = x2;
                                y1 = y2;
                            }
                        } // end for
                    } else {
                        paint.setColor(GlobalColor.colorFZAvePriceLine);
                        x1 = upQuoteX;
                        double cjje = quoteArray.getJSONArray(0).getDouble(0);
                        double avePrice = cjje;
                        double lastavg = 0;
                        if (avePrice > high) {
                            avePrice = high;
                        }
                        if (avePrice < low) {
                            avePrice = low;
                        }
                        if (avePrice >= close) {
                            temp = (avePrice - close) * scale;
                            y1 = topTitleHeight + upQuoteHeight - temp;
                        } else {
                            temp = (close - avePrice) * scale;
                            y1 = topTitleHeight + upQuoteHeight + temp;
                        }
                        lastavg = avePrice;
                        double xl = quoteArray.getJSONArray(0).getDouble(1);
                        double mathpjj = quoteArray.getJSONArray(0).getDouble(0) * xl;
                        for (int i = 1; i < quotelen; i++) {
                            x2 = upQuoteX + SPACE * i;
                            mathpjj += quoteArray.getJSONArray(i).getDouble(0)
                                    * (quoteArray.getJSONArray(i).getDouble(1)
                                            - quoteArray.getJSONArray(i - 1).getDouble(1));
                            if (mathpjj == 0) {
                                if (lastavg == 0) {
                                    avePrice = close;
                                } else {
                                    avePrice = lastavg;
                                }
                            } else {
                                avePrice = mathpjj / quoteArray.getJSONArray(i).getDouble(1);
                            }
                            lastavg = avePrice;
                            if (avePrice > high) {
                                avePrice = high;
                            }
                            if (avePrice < low) {
                                avePrice = low;
                            }
                            if (avePrice >= close) {
                                temp = (avePrice - close) * scale;
                                y2 = topTitleHeight + upQuoteHeight - temp;
                            } else {
                                temp = (close - avePrice) * scale;
                                y2 = topTitleHeight + upQuoteHeight + temp;
                            }
                            canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);

                            x1 = x2;
                            y1 = y2;
                        } // end for
                    }
                }
            } else {
                paint.setColor(GlobalColor.colorFZAvePriceLine);
                x1 = upQuoteX;
                double cjje = quoteArray.getJSONArray(0).getDouble(2);
                int scaleCount = 1;
                scaleCount = Utils.getCoefficient(exchange, stockcode);
                double cjsl = quoteArray.getJSONArray(0).getDouble(1) * scaleCount;
                double avePrice = cjje / cjsl;
                double lastavg = 0;
                if (cjsl == 0)
                    avePrice = close;
                if (avePrice > high) {
                    avePrice = high;
                }
                if (avePrice < low) {
                    avePrice = low;
                }
                if (avePrice >= close) {
                    temp = (avePrice - close) * scale;
                    y1 = topTitleHeight + upQuoteHeight - temp;
                } else {
                    temp = (close - avePrice) * scale;
                    y1 = topTitleHeight + upQuoteHeight + temp;
                }
                lastavg = avePrice;
                for (int i = 1; i < quotelen; i++) {
                    x2 = upQuoteX + SPACE * i;
                    cjje = quoteArray.getJSONArray(i).getDouble(2);
                    cjsl = quoteArray.getJSONArray(i).getDouble(1) * scaleCount; // ?
                    if (cjsl == 0) {
                        if (lastavg == 0) {
                            avePrice = close;
                        } else {
                            avePrice = lastavg;
                        }
                    } else {
                        avePrice = cjje / cjsl;
                    }
                    lastavg = avePrice;
                    if (avePrice > high) {
                        avePrice = high;
                    }
                    if (avePrice < low) {
                        avePrice = low;
                    }
                    if (avePrice >= close) {
                        temp = (avePrice - close) * scale;
                        y2 = topTitleHeight + upQuoteHeight - temp;
                    } else {
                        temp = (close - avePrice) * scale;
                        y2 = topTitleHeight + upQuoteHeight + temp;
                    }
                    canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);

                    x1 = x2;
                    y1 = y2;
                } // end for
            }
        }
    }

    // ??
    volumeX = LSpace;
    volumeY = topTitleHeight + upQuoteHeight + downQuoteHeight;
    volumeWidth = (int) graphicsQuoteWidth;
    volumeHeight = graphicsQuoteHeight - upQuoteHeight - downQuoteHeight;

    volume_row_height = volumeHeight / volume_row_num;

    paint.setColor(GlobalColor.clrLine);
    for (int i = 0; i <= volume_row_num; i++) {
        if (i == 0) {
            canvas.drawLine(volumeX, volumeY + volume_row_height * i, volumeX + volumeWidth,
                    volumeY + volume_row_height * i, paint);
        } else {
            if (i != volume_row_num)
                Graphics.drawDashline(canvas, volumeX, volumeY + volume_row_height * i, volumeX + volumeWidth,
                        volumeY + volume_row_height * i, paint);
        }
    }

    for (int i = 0; i < DIVIDE_COUNT; i++) {
        if (i == 0) {
            canvas.drawLine(volumeX + MINUTES / DIVIDE_COUNT * SPACE * i, volumeY,
                    volumeX + MINUTES / DIVIDE_COUNT * SPACE * i, volumeY + volumeHeight, paint);
        } else
            Graphics.drawDashline(canvas, volumeX + MINUTES / DIVIDE_COUNT * SPACE * i, volumeY,
                    volumeX + MINUTES / DIVIDE_COUNT * SPACE * i, volumeY + volumeHeight, paint);
    }

    if (this.isZs()) {
        //highVolume =  TickUtil.gethighAmount(quoteData.getJSONArray("data"));
        highVolume = highamount;
    } else {
        //highVolume =  TickUtil.gethighVolume(quoteData.getJSONArray("data"));
        highVolume = highvolume;
    }

    if (highVolume == 0) {
        if (this.isZs()) {
            // ?
            highVolume = volume_row_num * 4 * 100; // ???48highVolume=32
        } else {
            highVolume = volume_row_num * 4 * 100; // ???48highVolume=32
        }
    }
    if (highVolume < volume_row_num + 1)
        highVolume = volume_row_num + 1;
    scale = highVolume / volume_row_num;
    int volumeLabelY = volumeY + Font.getFontHeight(dTextSize) / 2;

    mpaint.setColor(GlobalColor.clr_tick_volume);
    for (int i = 0; i <= volume_row_num; i++) {
        if (i != volume_row_num) {
            AxisLabelVolume = highVolume - scale * i;
            if (this.isZs())
                AxisLabelVolume = Math.round(AxisLabelVolume / 10000);
            else
                AxisLabelVolume = Math.round(AxisLabelVolume);

            canvas.drawText(String.valueOf((int) AxisLabelVolume), upQuoteX,
                    volumeLabelY + volume_row_height * i, mpaint);
        }
    }

    // ??
    if (actualDataLen > 0) {
        scale = volumeHeight / highVolume;
        paint.setColor(GlobalColor.colorVolumeLine);
        double prevVol = 0;
        double temp = 0;
        for (int i = 0; i < actualDataLen; i++) {
            if (this.isZs())
                temp = (quoteArray.getJSONArray(i).getDouble(2) - prevVol) * scale;
            else
                temp = (quoteArray.getJSONArray(i).getDouble(1) - prevVol) * scale;
            float x1 = volumeX + SPACE * i;
            float y1 = (float) (volumeY + volumeHeight - temp);

            float x2 = x1;
            float y2 = volumeY + volumeHeight;
            canvas.drawLine((int) x1, (int) y1, (int) x2, (int) y2, paint);
            if (this.isZs())
                prevVol = quoteArray.getJSONArray(i).getDouble(2);
            else
                prevVol = quoteArray.getJSONArray(i).getDouble(1);
        }
    }

    drawTimeX(canvas);

    // 
    paint.setColor(GlobalColor.clrLine);
    canvas.drawLine(LSpace, graphicsQuoteHeight + topTitleHeight, LSpace + graphicsQuoteWidth,
            graphicsQuoteHeight + topTitleHeight, paint);

    if (isTrackStatus) {
        canvas.save();
        //??
        paint.setColor(GlobalColor.colorLine);
        canvas.drawLine(trackLineV, topTitleHeight, trackLineV, graphicsQuoteHeight + topTitleHeight, paint);
        canvas.restore();
    }
}

From source file:com.shine.demo.viewpager.smartTabLayout.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)}./*from   ww w  .j ava 2s  .c  o  m*/
 */
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.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    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(0, tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding);

    if (tabViewTextMinWidth > 0) {
        textView.setMinHeight(tabViewTextMinWidth);
    }

    return textView;
}

From source file:xyz.yhsj.helper.ViewHolderHelper.java

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

From source file:com.hao.common.adapter.BaseViewHolderHelper.java

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

From source file:cn.scujcc.bug.bitcoinplatformandroid.view.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)}.
 */// w w  w  . j  a  v a  2  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.setWidth(screenX);

    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.guerinet.materialtabs.TabLayout.java

/**
 * Sets up the title {@link TextView} as per the material guidelines
 *
 * @param textView The TextView//from www  .j ava 2s  . c  o  m
 */
private void prepareTextView(TextView textView) {
    //Keep it to 1 line or the selectors won't work
    textView.setSingleLine();

    //Set the text to all caps if we are in 14+
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        textView.setAllCaps(true);
    }

    //Tabs are bold
    textView.setTypeface(Typeface.DEFAULT_BOLD);
}

From source file:com.vgaw.androidtest.view.SlidingTabStrip.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  ww .  j  a  va  2s  .  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);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1f);
    textView.setLayoutParams(params);

    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.KlineMini.java

public void drawQuoteWin(Canvas canvas, JSONObject quoteData, int idx) throws JSONException {
    Paint mPaint = new Paint();
    mPaint.setTextAlign(Paint.Align.LEFT);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mPaint.setAntiAlias(true);//w  ww .  j av a  2  s. co m

    mPaint.setColor(GlobalColor.colorKlinePopub);
    mPaint.setTextSize(sTextSize);
    canvas.drawText(":", 0, axisLabelHeight, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 3, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 5, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 7, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 9, mPaint);
    canvas.drawText(":", 0, axisLabelHeight * 11, mPaint);

    mPaint.setTextAlign(Paint.Align.RIGHT);
    String qt = quoteData.getJSONArray("K").getJSONArray(idx).getString(0);
    double jrkp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(1);
    double zg = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(2);
    double zd = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(3);
    double sp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4);
    double preclose;
    if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) {
        switch (idx) {
        case 0:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(7);
            break;
        default:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(7);
            break;
        }
        if (quoteData.getJSONArray("K").length() == 1) {
            preclose = quoteData.getJSONArray("K").getJSONArray(0).getDouble(7);
        }
    } else {
        switch (idx) {
        case 0:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4);
            break;
        default:
            preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(4);
            break;
        }
        if (quoteData.getJSONArray("K").length() == 1) {
            preclose = quoteData.getDouble("zrsp");//quoteData.getJSONArray("K").getJSONArray(0).getDouble(4);
        }
    }
    //      if(quoteData.getJSONArray("K").length()==1 && quoteData.getJSONObject("todayData")!=null){
    //         preclose = quoteData.getJSONObject("todayData").getDouble("zrsp");
    //      }
    mPaint.setColor(getcolor(jrkp, preclose));
    canvas.drawText(Utils.dataFormation(jrkp, stockdigit), klineX, axisLabelHeight * 2, mPaint);
    mPaint.setColor(getcolor(zg, preclose));
    canvas.drawText(Utils.dataFormation(zg, stockdigit), klineX, axisLabelHeight * 4, mPaint);
    mPaint.setColor(getcolor(zd, preclose));
    canvas.drawText(Utils.dataFormation(zd, stockdigit), klineX, axisLabelHeight * 6, mPaint);
    mPaint.setColor(getcolor(sp, preclose));
    canvas.drawText(Utils.dataFormation(sp, stockdigit), klineX, axisLabelHeight * 8, mPaint);
    double zhangdie = sp - preclose;
    if (zhangdie > 0)
        mPaint.setColor(GlobalColor.colorpriceUp);
    else if (zhangdie < 0)
        mPaint.setColor(GlobalColor.colorPriceDown);
    else
        mPaint.setColor(GlobalColor.colorPriceEqual);
    canvas.drawText(Utils.dataFormation(zhangdie, 1), klineX, axisLabelHeight * 10, mPaint);
    if (quoteData.getString("period").equals("min5") || quoteData.getString("period").equals("min15")
            || quoteData.getString("period").equals("min30") || quoteData.getString("period").equals("min60")) {
        qt = qt.substring(4, 6) + '/' + qt.substring(6, 8) + ' ' + qt.substring(8);
    } else {
        qt = qt.substring(2, 4) + qt.substring(4, 6) + qt.substring(6, 8);
    }
    mPaint.setColor(GlobalColor.colorLabelName);
    canvas.drawText(qt, klineX, axisLabelHeight * 12, mPaint);
}

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

public void drawIndex(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);// ww  w. j  av a  2 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, 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);
            canvas.drawText("?", x, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width, -DY * 5);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("a"), true), x, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("b"), true), x, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("govbond"), true), x, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("fund"), true), x, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("warrant"), true), x, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("bond"), true), x, y, paint);

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

From source file:com.einzig.ipst2.activities.MainActivity.java

/**
 * This method fixes formatting when radio boxes are changed
 *//*from   w ww. j  a  v a2 s.  com*/
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    buttonView.setTypeface(isChecked ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
    Logger.d("Check Changed : " + buttonView.getText().toString() + " - " + isChecked);
    ThemeHelper.styleRadioButton(buttonView, this, isChecked);
}