How to add space at the start and end of eachline
<p>I have created a custom textview class and I am using BackgroundColorSpan to apply color in the background. How can I add blank space before and after each line. I really appreciate any help.</p><pre><br /><code>final String test_str1 = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";<br /><br /><br />public class CustomTextView extends TextView {<br /> public CustomTextView(Context context) {<br /> super(context);<br /> setFont();<br /> }<br /><br /> public CustomTextView(Context context, AttributeSet attrs) {<br /> super(context, attrs);<br /> setFont();<br /> }<br /><br /> public CustomTextView(Context context, AttributeSet attrs, int defStyle) {<br /> super(context, attrs, defStyle);<br /> setFont();<br /> }<br /><br /> private void setFont() {<br /> Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/TEXT.ttf");<br /> setTypeface(font, Typeface.NORMAL);<br /><br /> Spannable myspan = new SpannableString(getText());<br /> myspan.setSpan(new BackgroundColorSpan(0xFF757593), 0, myString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);<br /> txtview.setText(myspan);<br /> }<br />}<br /></code><br /></pre><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34525444/how-to-add-space-at-the-start-and-end-of-eachline">http://ift.tt/1Os7Vfn</a></h2>
Nhận xét
Đăng nhận xét