Hey, I have a simple list which contains Strings in Arabic, the problem is that some strings get a blank space on the begging of the word, so not all the words are allaigned properly..
Here is a screen shot of what I mean:
As you can see in the 3rd and 4th line, there is a blank space before the name, and the source of the strings there is no blank space.. Here are the 2 lines that get blank space that are in strings.xml:
<item>التاريخ الإسلامي</item>
<item>الحضارة الإسلامية</item>
Can anyone tell me why they get blank space?
Thanks.
It does not seem that you are doing anything wrong there. Try another font, as this might be a font issue. If that does not work, a workaround I would suggest you to set that text in code in the meantime.
If it is reproducible with several fonts, I believe you should post a bug report here:
http://code.google.com/p/android/issues/entry
Related
I like to think my title question is adequate, but the details are:
I have long strings (sentences in a story) to display and want it displayed in a number of textviews, with only one line in a box. If the string is too long, I want to truncate at a space or punctuation mark, then display the rest in another textview (or views if the string is really long). My display would have many textview, each with one piece of the string.
So, the question: how can I truncate a string at the end of a textview but not before? I do not know how many characters per line.
Second question: how do I capture the remaining piece of sentence and display it in the next textview?
The idea is to have a line of a complete sentence and a translation of the sentence appearing in the line below. If the sentence is longer than a single line, the truncated first part will have a truncated, translated line below it, then the remaining part of the original sentence below that, then the remaining part of the translated sentence below that. So, alternating lines of English text and Spanish text displayed.
For the line breaks, I suggest setting up a TextView that has the width of your on-display TextViews with wrap_content for its height. This will be an internal TextView that is for processing only and not for display. You will need to get the TextView to measure itself. This can get you started. Of course, if the text is already displayed on-screen, you can just use that TextView.
Once the view is measured, you can get its internal layout which most likely is a StaticLayout. (You can also use StaticLayout directly without the TextView.) Since the StaticLayout is a representation of the text display by the view and are the same lines of text that would display in the TextView, you can move them over directly to single-line, on-screen TextViews as long as those TextViews have the same characteristics as your internal one. StaticLayout has methods to retrieve individual lines of text.
There are details that you will have to work through, but that is the gist.
Update: I took the liberty of making a small demo app. This app takes a paragraph of text and splits it into the constituent lines. Those lines are then displayed on-screen with the original paragraph as seen below:
I'm building a grammatical text interpreter with a JavaFX GUI where you can just paste your text into a TextArea. This creates something of a problem though, since line breaks from MS Word are somehow formatted in a special way (both paragraphs (ENTER) and line breaks (SHIFT+ENTER).
If I copy the text to a plain .txt file and open it in a browser (tried Chrome, Safari and Firefox), I can copy it again from there without any problem. They somehow fix the issue.
Pasting the text into a new e-mail in Apple's mail and then copying it from there, fixes it, even pasting it into a JEditorPane (java swing), fixes it.
Notepad, TextEdit, Notes and Pages does NOT solve it.
But I need the ability to copy the text directly from a variety of sources and asking people to copy it to somewhere else is just not an option.
I searched for a solution before this post, and the general solution I could find was to replace "\r" with "\r\n", but this doesn't seem to help, as the line break is already lost, as soon as it has been pasted into the TextArea.
A different solution would of course be to simply use a JEditorPane instead of the TextArea, but when I create an AnchorPane and put a JEditorPane into it as a swingComponent, I get an area the size of the initial text, and editing that text on runtime doesn't change the size of that area (which is NOT the area of the contentPane).
Now, I know that I present different solution ideas here, and that I probably should just ask for how to get one specific thing to work, but I'm really getting a headache over this, so weather it's a way to get the contentPane to work properly with the layout, finding a way to make the TextArea keep these linebreaks or even something different is fine. I've just spent too much time trying to solve it now :(
I am trying to make a bizarre text editor for people with reading problems with Netbeans. You load the text you like and the editor starts highlighting it word by word with bold letters. The change from plain to bold constantly change the word dimensions and moves the line. One solution was the Monospaced Font but I would like to add a few more fonts available for the user to choose. Is there any way to do this with Arial for example by giving some orders to the JTextPane?
You can manually split the String with <br/> by counting characters and splitting at the right spot to keep the width under your desired character width. Give some leeway so if you get a big word, it won't still go to the next line.
Alternatively, you could use a JList to display your lines (instead of using <br/>). That way, there's no way the line would split to the next line. However, if you do it that way, the user will click on the list like a list and not be able to select text like in a normal text pane.
In my app I have line numbers to the left of an EditText - everything is great so far, the line numbers are perfectly aligned with the lines of the EditText.
The problem is, if the user changes the text size of the EditText the line numbers aren't aligned properly. So I've added code so when the text size of the EditText is changed, the line numbers text size is changed too; but that causes another problem: if the user picks a big text size, the line numbers hog all the space, so there's barely any room to write in the EditText.
The only solution would be to set line spacing. So I eventually came across the setLineSpacing() function, and have tried using it based off tutorials but I don't understand how it works and can't get it aligned with the EditText's lines.
Can someone help me understand how to use it, or suggest a different way of getting each line in the line numbers TextView aligned with the EditText's lines?
Sorry if this is confusing, I'm not very good at explaining things well sigh.
Thanks,
Alex.
I faced a similar situation in the past, in which the EditText's size was limited. It was decided that the max font size that can be chosen should be limited to a value in which the visual appearance does not look ugly. I feel it is useless to plug cases that can occur but don't make sense. It is better to block such cases. Perhaps you can think along these lines.
HTH,
Akshay
Kind of a strange question but... here it goes.
Recently my application threw an IOException that the text only had a clubs symbol in it (like the suit in cards) I know this is probably because there was a number in there that was cast to a char and printed to the screen, and I've found where that might have happened. The only problem is, I can't recreate it in eclipse because the eclipse console doesn't want to print those characters for me. All I get are boxes.
I figure this is an encoding issue or something but I need eclipse to print out those characters just like the windows console would. Is there a setting I can change to do this?
The respective Unicode character is U+2663. Just print "\u2663" and you should be fine. This has nothing to do with ASCII, though.
If you get boxes it may also be a font issue. If the font you selected for the console view in Eclipse does not have a glyph for that code point you'll get boxes, usually. The character might still correctly printed, though. Usually monospaced fonts have that character, though, since it was historically part of the glyphs for the control characters below character code 32 (not that control characters ever had the intention of a visual appearance, but well, they could be in the screen buffer, so someone thought it would be a good idea to display them as well).