webview html 问题汇总

webview 显示字体太小,后台可能适配没做好,没办法安卓端自己写了判断。

//根据屏幕密度设置

 DisplayMetrics dm = new DisplayMetrics();
 getWindowManager().getDefaultDisplay().getMetrics(dm);
  if (dm.densityDpi > 240 ) {
         settings.setDefaultFontSize(40); //可以取1-72之间的任意值,默认16
   }

webview加载url需要传header

Map<String, String> map = new HashMap<String, String>();
map.put(key,value);
webview.loadUrl(url,map);

textview.settext("");里面字体颜色不一样:
引号里放下面的代码
Html.fromHtml("<font color=#fc2d24>" + s1 + "<font/>"+"<font color=#030303>" + s2 + "<font/>")
 
 
时间戳转换
 public static String FomatDate(Long timecode){
        Date date = new Date(timecode);
        SimpleDateFormat sdf = new SimpleDateFormat("yy/MM/dd HH:mm");
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // public final String format(Date date)
        String s = sdf.format(date);
        System.out.println(s);
        return s;
    }


猜你喜欢

转载自blog.csdn.net/Zhao_Yanqing/article/details/59108620