• android webview正确显示音标


    package com.example.fonttest;
    
    import android.support.v7.app.ActionBarActivity;
    import android.webkit.WebView;
    import android.os.Bundle;
    
    public class MainActivity extends ActionBarActivity {
    
    	WebView wv;
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    		wv = (WebView) findViewById(R.id.wvShow);
    		String pish = "<html><head><style type="text/css">@font-face {font-family: MyFont;src: url("file:///android_asset/font/segoeui.ttf")}body {font-family: MyFont;font-size: medium;text-align: justify;}</style></head><body>";
    		String pas = "</body></html>";
    		String myHtmlString = pish + "/dɒɡ/" + pas;
    		wv.loadDataWithBaseURL(null,myHtmlString, "text/html", "UTF-8", null);
    	}
    
    }
    

    android系统自带的字体都不支持显示音标,只能自己把支持音标显示的字体加入项目中
    在 C:WindowsFontsSegoe UI目录下选择一个常规字体(segoeui.ttf)复制出来放在assets/font/目录下

    Keep it simple!
    作者:N3verL4nd
    知识共享,欢迎转载。
  • 相关阅读:
    第十三周学习进度条
    冲刺第四天
    第二天冲刺
    第三天冲刺
    第一天冲刺
    课下作业
    第十二周学习进度条
    课下作业
    webp与png、jpg相互转换
    Node疑难解决
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5834755.html
Copyright © 2020-2023  润新知