0

[enter image description here

If I use single type of font its working fine text is not cutting from edges.But when i tried to use two different font with different Text Style then the Text cutting from edges in Textview.

Typeface tfNormal = Typeface.createFromAsset(ctx.getAssets(), "fonts/futura_tee.ttf");
Typeface tfBold = Typeface.createFromAsset(ctx.getAssets(), "fonts/futura_tee_bold.ttf");

String msg="tournament sopan 20 nov offline double 2 was updated";
SpannableStringBuilder sb = new SpannableStringBuilder();

        final String t_name = "sopan 20 nov offline double 2";
        int startindex = msg.indexOf(t_name);
        int endindex = startindex + t_name.length();

        ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View textView) {
                //some click event
            }

            @Override
            public void updateDrawState(TextPaint ds) {
                ds.setUnderlineText(false);
                ds.setColor(ctx.getResources().getColor(R.color.blue_color));
                ds.setTypeface(tfBold);

            }
        };
        if (startindex >= 0) {
            sb.setSpan(clickableSpan, startindex , endindex , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE );
        }


        textview.setMovementMethod(LinkMovementMethod.getInstance());
       textview.setText(sb, TextView.BufferType.SPANNABLE);
        textview.setTypeface(tfNormal);
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74
Rakesh Sahu
  • 31
  • 1
  • 6

2 Answers2

0

I think issue is with your font file 'futura_tee_bold.ttf', just use any other font file in that place and check how it is working. If you want to use this font, try by removing margins and paddings to all parent views of that text view in xml.

Srikanth
  • 1,555
  • 12
  • 20
0

This question has already been answered here

You should not use setTypeface in your ClickableSpan. Actually, you should use two different spans for the same part of the text : one ClickableSpan and one TypefaceSpan.

If you want to use a custom font for the TypefaceSpan, see this post.

Community
  • 1
  • 1
Vrogar
  • 1
  • 2