Italic TextView with wrap_contents seems to clip the text at right edge

前端 未结 13 1370
孤独总比滥情好
孤独总比滥情好 2020-12-24 10:22


        
13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-24 11:19

    This is my solution: Format textview and measure. After that set width of textview with 1 pixel add to the width measured.

    TextView textView = new TextView(this);
    textView.setText("Text blah blah");
    textView.setTypeface(typeface, Typeface.BOLD_ITALIC)
    textView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    textView.setLayoutParams(new LayoutParams(textView.getMeasuredWidth() + 1, 
                                                 LayoutParams.WRAP_CONTENT));
    

    Working for me. Hope these help.

提交回复
热议问题