龙湖适配

Posted bozhiyao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了龙湖适配相关的知识,希望对你有一定的参考价值。

在一个项目中看到的移动端适配:

!function (e, t) {
      console.log(t);

      function i() {
        var t = n.getBoundingClientRect().width;
        console.log(n.getBoundingClientRect());
        t / d > s && (t = s * d);
        var i = t / 7.5;
        n.style.fontSize = i + "px", c.rem = e.rem = i
      }

      var a, r = e.document, n = r.documentElement, o = r.querySelector(‘meta[name="viewport"]‘),
        m = r.querySelector(‘meta[name="flexible"]‘), l = r.querySelector(‘meta[name="max-width"]‘), s = 1024, d = 0,
        p = 0, c = t.flexible || (t.flexible = {});
      if (o) {
        console.warn("将根据已有的meta标签来设置缩放比例");
        var u = o.getAttribute("content").match(/initial-scale=([d.]+)/);
        u && (p = parseFloat(u[1]), d = parseInt(1 / p))
      } else if (m) {
        var v = m.getAttribute("content");
        if (v) {
          var f = v.match(/initial-dpr=([d.]+)/), h = v.match(/maximum-dpr=([d.]+)/);
          f && (d = parseFloat(f[1]), p = parseFloat((1 / d).toFixed(2))), h && (d = parseFloat(h[1]), p = parseFloat((1 / d).toFixed(2)))
        }
      }
      if (l) {
        var g = l.getAttribute("content");
        g && (s = parseInt(g))
      }
      if (!d && !p) {
        var w = e.navigator.userAgent.match(/android[Ss]+AppleWebkit/(d{3})/i),
          x = e.navigator.userAgent.match(/U3/((d+|.){5,})/i), b = x && parseInt(x[1].split(".").join(""), 10) >= 80,
          A = e.navigator.appVersion.match(/(iphone|ipad|ipod)/gi);
        e.navigator.appVersion.match(/OS 9_3/), e.devicePixelRatio;
        d = e.devicePixelRatio || 1, A || w && w[1] > 534 || b || (d = 1), p = 1 / d
      }
      if (n.setAttribute("data-dpr", d), !o) if (o = r.createElement("meta"), o.setAttribute("name", "viewport"), o.setAttribute("content", "width=device-width,initial-scale=" + p + ", maximum-scale=" + p + ", minimum-scale=" + p + ", user-scalable=no,user-scalable=0,viewport-fit=cover"), n.firstElementChild) n.firstElementChild.appendChild(o); else {
        var F = r.createElement("div");
        F.appendChild(o), r.write(F.innerhtml)
      }
      e.addEventListener("resize", function () {
        clearTimeout(a), a = setTimeout(i, 300)
      }, !1), e.addEventListener("pageshow", function (e) {
        e.persisted && (clearTimeout(a), a = setTimeout(i, 300))
      }, !1), i(), c.dpr = e.dpr = d, c.refreshRem = i, c.rem2px = function (e) {
        var t = parseFloat(e) * this.rem;
        return "string" == typeof e && e.match(/rem$/) && (t += "px"), t
      }, c.px2rem = function (e) {
        var t = parseFloat(e) / this.rem;
        return "string" == typeof e && e.match(/px$/) && (t += "rem"), t
      }
    }(window, window.lib || (window.lib = {}));

 

以上是关于龙湖适配的主要内容,如果未能解决你的问题,请参考以下文章

如何从片段适配器启动活动

片段内带有基本适配器的列表视图

片段中ListView的android自定义适配器

片段中gridview的Android文本和图像适配器

将值从回收器适配器传递到android中的片段

错误:E/RecyclerView:未连接适配器;跳过片段上的布局