Using hebrew with the android emulator - android

I want to be able to run a "Hello World" application on my android emulator in hebrew
How can I do that? is it supported?
thanks

Though android does not have complete support for Hebrew if you are just displaying text, then it turns out to be pretty easy to do.
First you want to add a Hebrew font to your app. For this you simply put a true type font file (with Hebrew characters) in your assets directory. Then you load the font and use it on your view. For any view that inherits from TextView (which includes just about any view that displays text), you do the following:
AssetManager assets = getAssets();
Typeface font = Typeface.createFromAsset(assets, "hebrewfont.ttf");
view.setTypeface(font);
This will cause Hebrew characters to be visible. You may need to use the RTL mode character (\u200F) to force your text to display in the correct order. You may also need to set the gravity to right in order to right align the text.
I've found no way to get the scrollbar to appear on the left side. :( Cantilation marks to however display properly starting in android 2.2. I've tested Nequdot in all versions since 1.5, and they work as well. You may want to use some of the precombined characters, such as shuruq (\ufb35) instead of vav+dagesh (\u05d5\u05bc), as this isn't necessarily handled properly.
I have had good results with the DejaVu font, which is freely available.

Although this has been asked a long time ago, there is a native Hebrew support in later versions. The avd with API15 (Android 4.0.3) can display Hebrew nicely out of the box. I'm not sure which version is the earliest with this capability.

Related

What are the requirements for a font (OTF or TTF) so it works well on Android?

I'm having have some issues with using a custom font ( Typeface ) in Android.
What happens is that when rendering text in a TextView, the last line is often partially cut off vertically (the lower parts of letters like g, j, y, etc missing) , even if there's PLENTY of space below the text. I assume this is because there's something wrong with the custom font file ( an OTF file) that I'm using. This does only happen when using this custom font. If I use Android standard fonts, not setting my custom typeface, everything works fine.
Question: What are the requirements for font files for Android, so that they work correctly. (Please don't post workarounds for the issue, I'm aware of those. )
Both OTF & TTF fonts Will work fine in android,You have to take care of textsize and paddings arround it.

display built-in emoji keys for inputmethod

I'm building a custom soft keyboard for android and would like to add a layout to include the emoji keys similar to what the default android keyboard (AOSP) is doing. I've searched around but it seems that most people are trying to display custom emoji from images. I'm looking to show the built-in icons that comes with Android (as shown below):
It seems that I should be able to use the Unicode characters to send images from the keyboard, but my first attempt seems to generate only the older versions of the emojis. How do I support the latest emoji the phone can handle? Also, how do I display the emojis in my keyboard as in the image above?
Emoticons-Keyboard
1) instead emitos ,Iam replacing the ImageView containing an asset with a TextView containing a Unicode sequence.
After cross referencing Supported Unicode Sequences as well as the Visual Unicode Database I realized that **u1F601** was a 32 bit Unicode representation, and the 16bit representation can be set like :
EditText messageInput = (EditText) findViewById(R.id.message_input);
messageInput.getText().append("\ud83d\ude01");
2) http://android.appstorm.net/how-to/customization/how-to-use-emojis-on-your-android-device/
Go to https://en.m.wikipedia.org/wiki/Emoji to see which emojis your device supports with unicode.
As you know which emoji is shown depends on the font you use, so to get the latest emojis use NotoColorEmoji.ttf as font for your app.
Thanks for all the suggestions. What I got to work for showing an emoji layout in my custom keyboard was the following:
In the .xml layout file, for each emoji you want to add, create a line like this: <Key android:codes="0x1F602" android:keyLabel="\ud83d\ude02"/>
When committing the key, use: getCurrentInputConnection().commitText(String.valueOf(Character.toChars(primaryCode)), 1);
Emoticon support doesn't work like you think it does. There is no universal set of emojis supported by all android devices, and the emojis your device does support may show differently on different devices. Emojis are done on Android in 1 of 2 ways.
1)Unicode. What emojis the device supports then depends on the font the app is using. You just send the unicode just like you would normal text, and you'd display it on your keyboard by displaying that character. For this method, you guess on which ones the phone will support. And its a total guess, because it depends on what font the app is using.
2)Image spans. You embed an ImageSpannable into the text you send via commitText. The advantage of this is you're sure you have an image (you need to include the images with your app). The disadvantage is it can't be sent to another device, saved, and may not work in all apps (they may not be displaying spannable objects).

How to get system Android emoji drawable by unicode character?

I want to implement an android emoji keyboard just using emoji unicode array, without any extra res.
So for the emoji unicode character, I need to get the drawable from android system, if the system doesn't support the charactor, I just ignore this character.
After some basic research,
emojicon, https://github.com/rockerhieu/emojicon
emojicon, https://github.com/ankushsachdeva/emojicon
These implements all use self made resources.
use TextView setText, tv.setText("\u263A"); TextView can show the resource, but how can I get the resource?
Here's the problem- the system doesn't determine what characters can be displayed. The font does. The font needs to define how to draw every character it will display. That's why you'll see boxes or ? for missing characters- that's the font's default render. There is no method on Android to test if a character will display in a given font (although it would be really nice). And since there's no way to know what font the EditText is using, there's no way to know if a given character is supported. Your best bet is to limit yourself to characters defined in the default Android System font. But even then you're assuming the OEM didn't use a different default font, the user hasn't overridden it, and the app hasn't overridden it. Basically, you're forced to guess and hope.

How to display Thai diactirics properly on Android?

A short preface. Thai script has vowel signs that may appear above the consonants, and also there are diacritic signs (DS) that also appear above the consonants; when both vowel and DS present, they appear one above other, so the vowel is set above the consonant and the DS is set above the vowel.
I am writing an application that will display text in Thai. Everything looks perfect in the emulator (API 10) but not on the real device (Samsung GT-I9001 with Gingerbread 2.3.6).
I've prepared two pictures to illustrate the problem. I have a simple layout that has the only TextView at the top; two words พี่สาว and ไม้ are displayed in that view.
This is how it should look like (a screenshot from the emulator):
The first character has a vowel and a DS above the vowel, and the last character has the DS only.
And here is a screenshot from my phone:
Both DS have slid down and now the vowel and the DS overlap each other above the first character. Note that the last by one character appears lower than it should (it should be whole line tall like you may see on the first screenshot).
I've found that the problem is system-wide: I've copied these Thai words to a simple web page and loaded it in the web browser in my phone, and got the same problem. It seems like the font rendering is broken.
So the question: how to bypass this? Do I need to install fonts (how?) or maybe some language pack (again, how?), or the only way is upgrading the Android?
PS: no problem on Android 4.0.4. Perhaps only old versions are affected.
Update: WarrenFaith has given a promising advice about setting the custom font. However this appeared to be not as simple as it looks. I've tried several different fonts including Roboto (introduced in ICS), Verdana from the msttf Linux package, and some others. To see that the font is really loaded and applied, I've added some Latin and Cyrillic characters to my text.
The result is funny. Only the Latin and Cyrillic characters change, but not Thai ones. Looks like the fonts don't have the required glyphs and Android replaces them with ones rendered using some default font.
(I don't understand why Roboto didn't work; it's the official Android font—shouldn't it have full support for the whole Unicode?)
So it seems like I have to find the font that has Thai glyphs.
And I'm still wondering what font is used by default in Android 4.0.4.
Happy end: thanks to WarrenFaith's advice, Google, and this blog article.
If the default text/font is broken, you should provide a font you know that will work. To implement the font, you can use the following answers:
Android - Using Custom Font
Using a custom typeface in Android

Right to Left support for TextView in Android

I'm developing an application for Android in Persian. I fetch data from SQLite database and display them, using TextView. How can I display the text (that contains multiple lines ) from right to left?
Any Idea?
If the ROM supports right-to-left, which is most likely the case if you bought your mobile in the middle east, then you can set the gravity to right.
If Android does not support this natively (I'm not sure), you could create a string reverser that swaps the nth char with the string.length() - nth character until you have a reflected string, and then post that right justified.
If the ROM doesn't support right-to-left rendering, you could possibly use the java.text.Bidi class that implements the Unicode Bidi Algorithm.
This is an old question but since it wasn't asked very good it was not answered.
#Farina, I believe the answer you are looking for is here:
http://developer.android.com/guide/topics/resources/providing-resources.html
In essence: By creating a layout-ar folder right next to your layout folder and placing an rtl oriented layout file in it you can get it to show only on rtl selected devices. (ar stands for Arab, if using a different rtl language you may find the code here. Be-were that some devices support old-deprecated language codes so if it doesn't work try looking for older codes)

Categories

Resources