我试图使用以下代码支持Android2.x的devanagari字体(尽管Android2.x无法呈现devanagari字体)。除了“raswa”和“dirga”的一些问题外,代码工作得很好。能否在Android2.x中获得正确的devanagari表示?
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/mangal.ttf");
TextView txtviewword=(TextView) findViewById(R.id.textViewWord);
txtviewword.setTypeface(typeface);这是不正确的表示(来自Android2.3):

应该是这样的(来自Android4.4):

发布于 2014-08-08 17:44:24
在分析了我在这个问题上的情况后,我发现用字母表('akshar')替换'raswa‘的位置本身就能解决姜饼的问题。所以我换了“raswa”和“字母表”的位置。因此,这提供了解决问题的方法。
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
char[] array = content[1].toCharArray(); /*content[1] is a string containing the original version */
for(int i=0; i<array.length; i++){
char c = array[i];
int code = (int) c;
if (code == 2367){ //2367 is int value for 'raswa'
char temp = array[i-1];
array[i-1]=c;
array[i]=temp;
}
}
String str = String.copyValueOf(array); /*This string contains the swapped version(symantically its wrong, though. It's works as my solution.)*/
Log.d("DetailActivity", "from gingerbread");
Log.d("DetailActivity", str);
if(!content[1].equals(null))txtviewdevanagari.setText(str);
}else{
Log.d("DetailActivity", "from ICS+");
if(!content[1].equals(null))txtviewdevanagari.setText(content[1]);
}https://stackoverflow.com/questions/25188269
复制相似问题