I want to write Persian in Android Studio, but after typing Persian, Android Studio shows some strange characters. Of course it was right for about 3 months, but suddenly it's strange.
-
Are you sure this isn't just an encoding problem or that the font doesn't have glyphs for these characters (seeing how the tooltip can display it correctly)? What if you run the app – are they displayed correctly? – Ingo Bürk Apr 26 '15 at 08:53
-
use string resources for strings. then it will be ok. – Amir Ziarati Aug 16 '17 at 11:29
-
1Hey @Cœur, just the title caught my eye on this. Sure, I saw it, thanks. – Salek Aug 07 '19 at 12:30
5 Answers
In android studio 1.2 you should go to configure> settings> colors and fonts> font> use your scheme> uncheck show only monospaced fonts> and finally use tahoma font and apply and ok. Enjoy it!

- 41
- 1
In Android Studio go to settings--> editor--> font and colors--> font, check the "secondary font" checkbox and define a Farsi font from the list like "Nazanin". Also, uncheck the "show only monospaced font".

- 725
- 12
- 33
In android versions later than 3, you don't need anything but in earlier versions you must add Farsi.java to your app and in the code write text as follow:
MyTextView = (TextView) findViewById(R.id.MyTextView);
Typeface tf = Farsi.GetFarsiFont(this);
MyTextView.setTypeface(tf);
MyTextView.setText(Farsi.Convert("سلام"));
you cann't write farsi text in xml files in earlier versions!!! so I suggest to use newer versions of android.

- 883
- 7
- 17
-
-
write your string in strings.xml file in values folder and in the layout file use it as @string/string_name". this is works for me in android studio 1.1.0 – Mahmoud Apr 26 '15 at 09:08
-
-
-
-
the last thing that i can say is in your build.gradle add the following pice of code: android { ... compileOptions.encoding = 'UTF-8' – Mahmoud Apr 26 '15 at 09:41
select your project in android studio and go to File/Setting menu
. in the opened page point to File Encodings
option and in that tabbed ensure IDE Encoding
is UTF-8

- 883
- 7
- 17
For Android Studio 1.5 in Windows create file with name "idea.properties" in
C:\Users\.AndroidStudio1.5
and write this in the file:
editor.new.rendering=true

- 2,802
- 6
- 23
- 34