Example usage for android.widget TextView getLineHeight

List of usage examples for android.widget TextView getLineHeight

Introduction

In this page you can find the example usage for android.widget TextView getLineHeight.

Prototype

public int getLineHeight() 

Source Link

Document

Gets the vertical distance between lines of text, in pixels.

Usage

From source file:app.abhijit.iter.MainActivity.java

private void setupGettingStartedHint() {
    TextView gettingStartedHint = (TextView) findViewById(R.id.hint_getting_started);
    int lineHeight = gettingStartedHint.getLineHeight();
    Drawable hamburgerIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_hamburger, null);
    hamburgerIcon.setBounds(0, 0, lineHeight, lineHeight);
    SpannableStringBuilder hintText = new SpannableStringBuilder();
    hintText.append(getResources().getString(R.string.hint_getting_started_1)).append(" ");
    hintText.setSpan(new ImageSpan(hamburgerIcon), hintText.length() - 1, hintText.length(), 0);
    hintText.append(getResources().getString(R.string.hint_getting_started_2));
    gettingStartedHint.setText(hintText);
}

From source file:com.juick.android.JuickMessagesAdapter.java

public static float getLineHeight(Context context, double scale) {
    Integer integer = lineHeights.get(scale);
    if (integer == null) {
        TextView textView = new TextView(context);
        textView.setTextSize((int) (getDefaultTextSize(context) * scale));
        integer = textView.getLineHeight();
        lineHeights.put(scale, integer);
    }/* w  w w.  java 2  s.  c om*/
    return integer;
}

From source file:com.vuze.android.remote.activity.LoginActivity.java

private void setupGuideText(TextView tvLoginGuide) {
    AndroidUtilsUI.linkify(tvLoginGuide);
    CharSequence text = tvLoginGuide.getText();

    SpannableStringBuilder ss = new SpannableStringBuilder(text);
    String string = text.toString();

    new SpanBubbles().setSpanBubbles(ss, string, "|", tvLoginGuide.getPaint(),
            AndroidUtilsUI.getStyleColor(this, R.attr.login_text_color),
            AndroidUtilsUI.getStyleColor(this, R.attr.login_textbubble_color),
            AndroidUtilsUI.getStyleColor(this, R.attr.login_text_color));

    int indexOf = string.indexOf("@@");
    if (indexOf >= 0) {
        int style = ImageSpan.ALIGN_BASELINE;
        int newHeight = tvLoginGuide.getBaseline();
        if (newHeight <= 0) {
            newHeight = tvLoginGuide.getLineHeight();
            style = ImageSpan.ALIGN_BOTTOM;
            if (newHeight <= 0) {
                newHeight = 20;/*  ww w. j  a v a2s .  c  om*/
            }
        }
        Drawable drawable = ContextCompat.getDrawable(this, R.drawable.guide_icon);
        int oldWidth = drawable.getIntrinsicWidth();
        int oldHeight = drawable.getIntrinsicHeight();
        int newWidth = (oldHeight > 0) ? (oldWidth * newHeight) / oldHeight : newHeight;
        drawable.setBounds(0, 0, newWidth, newHeight);

        ImageSpan imageSpan = new ImageSpan(drawable, style);
        ss.setSpan(imageSpan, indexOf, indexOf + 2, 0);
    }

    tvLoginGuide.setText(ss);
}

From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java

/**
 * @return the max height in pixels the description can be such that the
 *         action nicely takes up the entire screen.
 *//*from  w w  w. j av a  2 s .c  o  m*/
private int getDescriptionMaxHeight(Context context, TextView title) {
    // The 2 multiplier on the title height calculation is a
    // conservative estimate for font padding which can not be
    // calculated at this stage since the view hasn't been rendered yet.
    return (int) (mDisplayHeight - 2 * mVerticalPadding - 2 * mTitleMaxLines * title.getLineHeight());
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

/**
 * ? thumbnail view  ?  ?  ?./*from   w w w  . jav a2  s .c om*/
 *  ??  thumbnail view   {@link #thumbnailWidth}
 */
private FloatingModel[] measureFloatingModels(LayoutInflater inflater) {
    Point displaySize = AppearanceUtils.getDisplaySize(activity.getWindowManager().getDefaultDisplay());

    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.post_item_layout, (ViewGroup) rootView, false);

    TextView commentView = (TextView) view.findViewById(R.id.post_comment);
    TextPaint textPaint = commentView.getPaint();
    int textLineHeight = Math.max(1, commentView.getLineHeight());
    int rootWidth = (int) (displaySize.x * settings.getRootViewWeight());
    postItemPadding = view.getPaddingLeft() + view.getPaddingRight();
    int textWidth = postItemWidth = rootWidth - postItemPadding;

    View thumbnailView = view.findViewById(R.id.post_thumbnail);
    ViewGroup.MarginLayoutParams thumbnailLayoutParams = (ViewGroup.MarginLayoutParams) thumbnailView
            .getLayoutParams();
    thumbnailMargin = thumbnailLayoutParams.leftMargin + thumbnailLayoutParams.rightMargin;

    View attachmentTypeView = thumbnailView.findViewById(R.id.post_thumbnail_attachment_type);
    FloatingModel[] floatingModels = new FloatingModel[2];

    attachmentTypeView.setVisibility(View.GONE);
    thumbnailView.measure(displaySize.x, displaySize.y);
    Point thumbnailSize = new Point(thumbnailMargin + thumbnailView.getMeasuredWidth(),
            thumbnailView.getMeasuredHeight());
    floatingModels[0] = new FloatingModel(thumbnailSize, textWidth, textPaint);

    attachmentTypeView.setVisibility(View.VISIBLE);
    thumbnailView.measure(displaySize.x, displaySize.y);
    thumbnailSize = new Point(thumbnailMargin + thumbnailView.getMeasuredWidth(),
            thumbnailView.getMeasuredHeight());
    floatingModels[1] = new FloatingModel(thumbnailSize, textWidth, textPaint);

    thumbnailWidth = thumbnailSize.x;
    maxItemLines = divcell(thumbnailSize.y, textLineHeight);

    return floatingModels;
}