How to get this special space character ␣ into an Android Button? -
i want symbolize space in android button so:
- in strings.xml file define
<string name="spacesymbol">␣</string>
- in layout xml file set
android:text
"@string/spacesymbol"
when run application button shows nothing. ideas? if other character symbolizes space works other ␣ i'll glad use it
you can wrap space char in ![cdata[ ... ]] in string resource..that may bring in. should check character in roboto font also
given character not represented in roboto font, can use spannablestring replace special character own image:
you should create drawable (or bitmap) space image in want use. in example assigned variable 'drawable':
spannablestring textspan = new spannablestring(sb); pattern pattern = pattern.compile("#_", pattern.case_insensitive); matcher = pattern.matcher(textspan); while(matcher.find()) { textspan.setspan(new imagespan(this, drawable, imagespan.align_baseline), matcher.start(), matcher.end(), spanned.span_inclusive_inclusive); }
in string (in code example) have replaced space symbol 2 characters "#_". pattern find each occurence of "#_" , replace drawable.
then can use spannablestring charsequence argument anywhere it's defined (toast.maketext, textview.settext, etc) :
textview tv = (textview) findviewbyid(..); tv.settext(textspan);
Comments
Post a Comment