String str = "TEST BOLD TEST"; SpannableString spannableString = new SpannableString(str); spannableString.setSpan(new StyleSpan(Typeface.BOLD), str.indexOf("BOLD"), str.indexOf("BOLD") + "BOLD".length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, 30); tv.setTextColor(Color.BLACK); tv.setText(spannableString); tv.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); new ViewPrintJob.Builder().view(tv).build().print(getApplicationContext(), mAccount);
Can I print a Layout view? How can I set that layout to be the length of the paper (Mini/Station) but my own height (in case it's a long receipt)?
I believe my question could be answered here @Raymond Lee
https://clover.cloud.answerhub.com/questions/10304/viewprintjob-centering-on-receipt.html
Yes, you can print a Layout view, and you can set the layout width to be 576 pixels for Clover Station, and 394 pixels for all other devices (width of receipt paper, see here), and the height to whatever you want.
I answered the question you linked with more details on ViewPrintJob as well.
2 People are following this question.