2011-01-24 58 views
5

我想为我的Android应用程序提供阿拉伯语言支持。 Android 2.3默认提供阿拉伯语支持。所以,我想知道在Android中为阿拉伯语提供支持时是否需要执行任何UI更改。
由于阿拉伯语中的字母是从右到左编写的,我需要在Android UI布局设计和编码中遵循哪些约束条件?
否则,否则Android会自行处理读取我们输入的数据,无论是从右到左输入。Android中阿拉伯语支持应用程序的UI设计

谁能帮我解决这个问题吗?

+0

我也面临同样的问题任何人都可以建议... – 2011-10-01 13:08:52

回答

1

我用这个代码和工作完美试试吧..

public static void change_setting_arabic(Context con) { 
           try { 
               Locale locale = new Locale("ar"); 

               Class amnClass = Class.forName("android.app.ActivityManagerNative"); 
               Object amn = null; 
               Configuration config = null; 

               // amn = ActivityManagerNative.getDefault(); 
               Method methodGetDefault = amnClass.getMethod("getDefault"); 
               methodGetDefault.setAccessible(true); 
               amn = methodGetDefault.invoke(amnClass); 

               // config = amn.getConfiguration(); 
               Method methodGetConfiguration = amnClass 
                       .getMethod("getConfiguration"); 
               methodGetConfiguration.setAccessible(true); 
               config = (Configuration) methodGetConfiguration.invoke(amn); 

               // config.userSetLocale = true; 
               Class configClass = config.getClass(); 
               Field f = configClass.getField("userSetLocale"); 
               f.setBoolean(config, true); 

               // set the locale to the new value 
               config.locale = locale; 

               // amn.updateConfiguration(config); 
               Method methodUpdateConfiguration = amnClass.getMethod(
                       "updateConfiguration", Configuration.class); 
               methodUpdateConfiguration.setAccessible(true); 
               methodUpdateConfiguration.invoke(amn, config); 

           } catch (Exception e) { 
               // TODO: handle exception 
               Log.d("error lang change-->", "" + e.getMessage().toString()); 
           } 
       } 
0

从罗马Nurik有点Pro尖端(从Android团队):
开始和结束使用比重,而不是LEFT和RIGHT更好的RTL支持。尽管常量只在API 14 [0]中定义,但它们向后兼容,因为它们在编译时内联,(2)它们在功能上等同于早期设备上的LEFT和RIGHT,显著字节:

START = 0x00800003
LEFT = 0x00000003
END = 0x00800005
RIGHT = 0x00000005

您可以看到与
<TextView layout_width=match_parent, gravity=start, text=[hebrew characters here]>
文本LAYO开始之间的差异LEFT ut会看到您的希伯来字符,并将文本对齐到TextView的右边界,而不是左边,因为重力=开始。注意,TextView的默认水平引力是开始的,而不是左侧。

因此,左总是左和右永远是正确的,但开始和结束可以是左或右,这取决于区域设置。