I want to format time like 5h45'12" but I'd like to make the 'h' top index in TextView. Is there easy way to do that without making several TextViews for each part of the time?
You can try to copy this character and use it: ʰ
It's a superscript h. So it will look like:
5ʰ45'12"
I'm not sure if this is what you like, and also not sure if it will work on Android but you can try.
Related
There are 2 options available to apply edit-text style on fly.
One is concat the string with html tags and set text by using Html.fromHtml method.
Second one is create span objects based on the selected style and set the span into spannable object.
Now my doubt is "which is better way to apply or change the edit-text style on typing?".
Can someone explain help me?
Spannable is much more better solution because its faster compared to html process. Also have an easy framework to work with it like SpannableStringBuilder. You can find another libraries to create spannables on the web. Most important thing is in my opinion you can recycle Spannable objects on fly which is memory-friendly.
my problem is that I can't put '\u221c' unicode on button in Android app. '\u221a' is OK and works, but 221b and 221c doesn't. Also, when I want that button to put text '\u221c' in EditText it puts \u221a. I dont know why it works that way and how to fix this. Please help
This appears to be simply a font problem. U+221A SQUARE ROOT “√” is a much more common character in fonts than U+221B CUBE ROOT “∛” and U+221C FOURTH ROOT “∜”. You may need to find a font that contains them and bundle it into the application, or use other notations.
You can, in particular, use fractional powers instead of roots. That’s even the preferred way, according to the standard ISO 80000-2. So instead of ∜a, you would use “a” followed by “1/4” in superscript style, if that’s possible in the application.
I often read such messages. But what is the reason of the replacement? I only know that a space bar cannot be at the end of a string because it will be ignored and you will get the string without the space bar.
<string name="lorem">Lorem and a space bar </string>
But what about everything else? I don't see any visual difference between
<string name="loading">Loading…</string>
and
<string name="loading">Loading...</string>
have a look at this answer. This is just to use less characters if possible and there is no point making three dots if the appropriate character is available for this. It's good to use Unicode value in this case. You can also tell Lint to ignore this if you with.
Android Replace "..." with ellipsis character
The screenshot below displays my problem.
The first EditText shows a hint in Arabic which is shifted upwards, now the second EditText is just for reference which shows the English version completely fine. Same goes for the Button.
I have declared the string in strings.xml like this:
<string name="ar_login">دخول</string>
This is how I set the EditText's hint:
UserName.setTypeface(ArabicFont);
String hint = getString(R.string.ar_HintUserName);
....
UserName.setHint(hint);
UPDATE:
I used this, but of no use:
UserName.setGravity(Gravity.CENTER_VERTICAL);
But with this, Text moved a little down; but i guess its not generic:
UserName.setPadding(0,15,0,0);
With Padding, English words move to downwards.
UPDATE 2:
Originally arabic texts are separated; means they are shown letter by letter. So to join them, i was using this Arabic Reshaper. To Download Code, Check this link
Now when i reshape the arabic text and then set on TextView or as EditText's Hint, it got shifted upwords but without reshaping it is fine.
So i guess, whether i have to change the reshape class OR make my textview to not split the word. But dont know where to go?
I am still unable to find out why Android splits the arabic words into separate letters anyhow in my second edit I am providing a link which uses a class to rejoin the separated letters and form a word again.
In the reshape function, it was mistakenly appending \n at the end, just removing it solves the problem.
I am sure its problem with the font file which you are using.!
[Sorry I am not allowed to upload the screen shot as my reputations are lower :(]
For the layout, I was setting text in xml, and typeface in code. And I'm not setting any attributes like padding/gravity. But it was working fine for me.
So, I can assure you that using font file whose style matches your requirement will solve your problem.
Just to help you out with, but 'm not sure I got font file from DroidSansFallback.ttf
Just a guess :) ...,
What if the size of the Arabic font is lower? [If this is the case, then Gravity.CENTER_VERTICAL should have worked for you :( ]
May be this is the style of that font file. How about trying a different font file for Arabic text ?
I am looking to format text line by line in a text view or similar. I want to be able to have line by line justifcation and formatting, almost like a word document (though nothing like as extensive)
I basically need to be able to have a continuous document with some parts right justified, some parts centered. Some bold, some not and some with a coloured background and some white. Also alowing the user to choose font.
Can someone recommend an decent approach to this please.
thanks
TextView/EditText operates on fairly rich text described by the various style span objects here: http://developer.android.com/reference/android/text/style/package-summary.html
For example you can use this to build text containing those various style spans: http://developer.android.com/reference/android/text/SpannableStringBuilder.html
SpannableStringBuilder is-a CharSequence, so it can be set as the text in a TextView. Though more often you probably just want to use TextView.getEditableText() to return the Editable interface to the text inside of the text view which allows you to modify its contents including style spans.
TextView supports most of what you are asking for through style spans, though justification is applied per-paragraph and not per-line. (Per-line is weird... I don't think even Word does such a thing?)
I would recommend using multiple TextViews. Possibly, one for each line if you really need the text that different. You can customize each one however you want fairly easily. If you haven't already, take a look at the documentation: http://developer.android.com/reference/android/widget/TextView.html
Then, you could use a RelativeLayout or a LinearLayout to position them however you need. Just ask if you have any other questions.