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:de.schildbach.wallet.ui.EncryptKeysDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.encrypt_keys_dialog, null);

    oldPasswordGroup = view.findViewById(R.id.encrypt_keys_dialog_password_old_group);

    oldPasswordView = (EditText) view.findViewById(R.id.encrypt_keys_dialog_password_old);
    oldPasswordView.setText(null);/*from w  ww  .  j  a v a  2  s .  co m*/

    newPasswordView = (EditText) view.findViewById(R.id.encrypt_keys_dialog_password_new);
    newPasswordView.setText(null);

    badPasswordView = view.findViewById(R.id.encrypt_keys_dialog_bad_password);
    attemptsRemainingTextView = (TextView) view.findViewById(R.id.pin_attempts);

    passwordStrengthView = (TextView) view.findViewById(R.id.encrypt_keys_dialog_password_strength);

    showView = (CheckBox) view.findViewById(R.id.encrypt_keys_dialog_show);

    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.encrypt_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.button_ok, null); // dummy, just to make it show
    if (getArguments().getBoolean(CANCELABLE_ARG)) {
        builder.setNegativeButton(R.string.button_cancel, null);
    }

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(final DialogInterface d) {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);

            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    handleGo();
                }
            });

            oldPasswordView.addTextChangedListener(textWatcher);
            newPasswordView.addTextChangedListener(textWatcher);

            showView = (CheckBox) dialog.findViewById(R.id.encrypt_keys_dialog_show);
            showView.setOnCheckedChangeListener(
                    new ShowPasswordCheckListener(newPasswordView, oldPasswordView));
            showView.setChecked(true);

            EncryptKeysDialogFragment.this.dialog = dialog;
            updateView();
        }
    });

    return dialog;
}

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

private void drawWin(Canvas canvas) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);//from   ww w.ja  v a  2 s  . c  o  m

    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(closeRight)));
    //???
    //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 = "";
    title2 = "";

    mpaint.setColor(GlobalColor.colorLabelName);

    canvas.drawText(title7 + title8, LSpace, axisLabelHeight - 5, mpaint);
    canvas.drawText(title1, LSpace + mpaint.measureText(":00:0000"), axisLabelHeight - 5, mpaint);
    canvas.drawText(title2, LSpace + mpaint.measureText(":00:0000:"), 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);
    }

    // 
    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);
    }

    // ??
    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);
    }
    // 
    canvas.drawLine(LSpace, graphicsQuoteHeight + topTitleHeight, LSpace + graphicsQuoteWidth,
            graphicsQuoteHeight + topTitleHeight, paint);
}

From source file:be.digitalia.fosdem.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  ww . j a va 2  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 = (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) {
            tabView.setSelected(true);
        }
    }
}

From source file:com.mickledeals.views.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  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_PX,
            context.getResources().getDimensionPixelSize(R.dimen.sp_17));
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(Color.argb((int) (MIN_TEXT_ALPHA * 255), 255, 255, 255));
    textView.setBackgroundResource(R.drawable.selector_bg);

    //        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.starshow.app.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)}.//from  www  . jav a 2 s . c o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setBackgroundColor(getResources().getColor(R.color.white));
    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);

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

    return textView;
}

From source file:com.sina.weibo.sdk.widget.LoginButton1.java

/**
 * /* w  w  w  .j  a  v  a2 s .  c  o m*/
 *
 * @param attrs XML 
 */
private void loadDefaultStyle(AttributeSet attrs) {
    if (attrs != null && 0 == attrs.getStyleAttribute()) {
        Resources res = getResources();
        this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue);
        this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left),
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top),
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right),
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom));
        this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0);
        this.setCompoundDrawablePadding(
                res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding));
        this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size));
        this.setTypeface(Typeface.DEFAULT_BOLD);
        this.setGravity(Gravity.CENTER);
        this.setText(R.string.com_sina_weibo_sdk_login_withweb);
    }
}

From source file:com.quran.labs.androidquran.widgets.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    final float fontSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP,
            metrics);/* ww w  . j  a va 2 s.  c o m*/
    final TextPaint paint = new TextPaint();
    paint.setTextSize(fontSize);
    paint.setTypeface(Typeface.DEFAULT_BOLD);

    int targetWidth = 0;
    final int tabs = adapter.getCount();
    for (int i = 0; i < tabs; i++) {
        String str = adapter.getPageTitle(i).toString();
        str = str.toUpperCase(Locale.getDefault());

        int width = (int) paint.measureText(str);
        width = width + 2 * mTabPadding;
        if (width > targetWidth) {
            targetWidth = width;
        }
    }

    if (targetWidth * tabs < metrics.widthPixels) {
        targetWidth = metrics.widthPixels / tabs;
    }

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        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);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (tabTitleView != null) {
            tabTitleView.setText(adapter.getPageTitle(i));
        }
        tabView.setOnClickListener(tabClickListener);

        final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(targetWidth,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        mTabStrip.addView(tabView, params);
    }
}

From source file:la.mejorando.prelollipopmaterialdesign.views.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 w w.  j  ava2s .  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.setTextAppearance(context, R.style.SlidingTextViewStyle);

    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:net.hadifar.dope.ui.widget.pagerIndicator.NumericPageIndicator.java

@SuppressWarnings("deprecation")
public NumericPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;// ww  w  .ja va  2  s  .co m
    }

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultTextColor = res.getColor(R.color.default_page_number_indicator_text_color);
    final int defaultPageNumberTextColor = res
            .getColor(R.color.default_page_number_indicator_page_number_text_color);
    final boolean defaultPageNumberTextBold = res
            .getBoolean(R.bool.default_page_number_indicator_page_number_text_bold);
    final int defaultButtonPressedColor = res
            .getColor(R.color.default_page_number_indicator_pressed_button_color);
    final float defaultTopPadding = res.getDimension(R.dimen.default_page_number_indicator_top_padding);
    final float defaultBottomPadding = res.getDimension(R.dimen.default_page_number_indicator_bottom_padding);
    final float defaultTextSize = res.getDimension(R.dimen.default_page_number_indicator_text_size);
    final boolean defaultShowChangePageButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_change_page_buttons);
    final boolean defaultShowStartEndButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_start_end_buttons);

    // Retrieve styles attributes
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumericPageIndicator, defStyle, 0);

    mTextTemplate = a.getString(R.styleable.NumericPageIndicator_textTemplate);
    if (mTextTemplate == null) {
        mTextTemplate = res.getString(R.string.default_page_number_indicator_text_template);
    }
    parseTextTemplate();

    mTextPreviousButton = a.getString(R.styleable.NumericPageIndicator_previousButtonText);
    if (mTextPreviousButton == null) {
        mTextPreviousButton = res.getString(R.string.default_page_number_indicator_previous_button_text);
    }
    mTextNextButton = a.getString(R.styleable.NumericPageIndicator_nextButtonText);
    if (mTextNextButton == null) {
        mTextNextButton = res.getString(R.string.default_page_number_indicator_next_button_text);
    }

    mColorText = a.getColor(R.styleable.NumericPageIndicator_android_textColor, defaultTextColor);
    mColorPageNumberText = a.getColor(R.styleable.NumericPageIndicator_pageNumberTextColor,
            defaultPageNumberTextColor);
    mPageNumberTextBold = a.getBoolean(R.styleable.NumericPageIndicator_pageNumberTextBold,
            defaultPageNumberTextBold);
    mColorPressedButton = a.getColor(R.styleable.NumericPageIndicator_pressedButtonColor,
            defaultButtonPressedColor);
    mPaddingTop = a.getDimension(R.styleable.NumericPageIndicator_android_paddingTop, defaultTopPadding);
    mPaddingBottom = a.getDimension(R.styleable.NumericPageIndicator_android_paddingBottom,
            defaultBottomPadding);
    mPaintText.setColor(mColorText);
    mShowChangePageButtons = a.getBoolean(R.styleable.NumericPageIndicator_showChangePageButtons,
            defaultShowChangePageButtons);
    mShowStartEndButtons = a.getBoolean(R.styleable.NumericPageIndicator_showStartEndButtons,
            defaultShowStartEndButtons);

    mPaintButtonBackground.setColor(mColorPressedButton);
    final float textSize = a.getDimension(R.styleable.NumericPageIndicator_android_textSize, defaultTextSize);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);

    mPaintPageNumberText.setColor(mColorPageNumberText);
    mPaintPageNumberText.setTextSize(textSize);
    mPaintPageNumberText.setAntiAlias(true);
    if (mPageNumberTextBold) {
        mPaintPageNumberText.setTypeface(Typeface.DEFAULT_BOLD);
    }

    final Drawable background = a.getDrawable(R.styleable.NumericPageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();
}

From source file:com.yek.keyboard.keyboards.views.CandidateView.java

/**
 * If the canvas is null, then only touch calculations are performed to pick
 * the target candidate./*from  ww w  .  j a v a 2 s .  c  o  m*/
 */
@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 + mXGap * 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) - mXGap;
                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();
    }
}