How to change the font size while printing in android?

后端 未结 2 1514
情书的邮戳
情书的邮戳 2021-01-11 14:43

I am sending the text to the bluetooth printer via my android cell. Both the printer and my device are connected via the bluetooth. It\'s Working fine and I

2条回答
  •  既然无缘
    2021-01-11 15:19

    I am not sure, but you may be able to achieve this with the Java span method for setting up font style.

    Try something like this:

    int start=editbox.getSelectionStart();
    
    int end=editbox.getSelectionEnd();
    
    Spannable span=(Spannable)editbox.getText();
    
    StyleSpan f = new StyleSpan( 
                            Typeface.createFromAsset(getAssets(),
                             "fonts/genbkbasr.ttf"));
    
    span.setSpan(f, start,end, 0);
    

    Similarly, you can apply font style, font color etc...

    For more detail check these:

    Android Development: How To Replace Part of an EditText with a Spannable

    How to use SpannableString with Regex in android?

提交回复
热议问题