Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the text direction from right to left

I want to write text in (right to left language i.e. Arabic) in a TextView. But I want to make the text writing direction from right to left. gravity:rightwill align the text to right only. I want to justify the text from right to left ( to make the words and numbers appear in he entered order in the line ) . how ?

like image 549
Adham Avatar asked Jun 09 '12 20:06

Adham


People also ask

How do I make text go from right-to-left?

To switch between RTL (Right-To-Left) and LTR (Left-To-Right) text directions, you need to click Ctrl + Shift : Ctrl + Left Shift for LTR . Ctrl + Right Shift for RTL .

How do you flip text direction?

Select the text box that you want to rotate or flip, and then select Format. Under Arrange, select Rotate.

How do you make text go from right-to-left in HTML?

Setting up a right-to-left pageAdd dir="rtl" to the html tag any time the overall document direction is right-to-left (RTL). This sets the default base direction for the whole document. All block elements in the document will inherit this setting unless the direction is explicitly overridden.


1 Answers

Another clever way which can be used in older versions of android and can be used anywhere in string so it's handier even in latest version of android, is to include the right-to-left mark or even left-to-right mark in the string when it's needed:

left-to-right mark: ‎ or ‎ (U+200E) right-to-left mark: ‏ or ‏ (U+200F) 

This is how it's down:

String rtl = "Hello \u200F(سلام)"; 

The good thing about this method is you can even use it after punctuation like (,{,[,! which are positioned right incorrectly! examples:

سلام! // wrong position سلام!‏ // right position by adding RLM after ! 

look how ! is positioned correctly in second line, actually there is an RLM after it, and you can copy paste it even if it's invisible.

The second good thing as you saw it is that you can use this method (these char codes) in any system that supports RTL like browsers, word and so on.

like image 104
Ali Avatar answered Sep 28 '22 04:09

Ali