zoukankan      html  css  js  c++  java
  • android适配知识总结

    一、http适配

      背景:API升级到28以后,不再支持明文的网络请求,只支持https请求。运行所报错误:java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security policy

      解决方案:

        1、//.在res目录下,新建xml目录,在xml目录下新建`network_security_config.xml`文件

         <?xml version="1.0" encoding="utf-8"?>
         <network-security-config>
           <base-config cleartextTrafficPermitted="true" />
         </network-security-config>

        2、在manifest的application下设置如下属性

          android:networkSecurityConfig="@xml/network_security_config"

    二、对18:9的屏幕适配

      背景:会出现上下黑边的情况.

      解决方案:

        在AndroidManifest.xml文件中,对application做一下处理,如下所示。

        <application>

        .............

        <meta-data android:name="android.max_aspect" android:value="2.1" />

        .............

        </application>

    
    

    三、对webview是否使用明文流量的适配

      背景:targetSdkVersion为27或更低的应用程序的android:usesCleartextTraffic默认值为“ true”。面向API级别28或更高级别的应用默认为“ false”时,webview加载不出来界面。

      解决方案:

        在AndroidManifest.xml文件中,给application标签的android:usesCleartextTraffic属性设置为true。

  • 相关阅读:
    Excel技巧大全
    2019年6月27日单词
    HTML5(12) 实时通讯WebSocket
    C#(99):随机数Random
    C#(99):C# 8.0 的新特性( NET Framework 4.8 与 Visual Studio 2019 )
    2019年6月13日单词
    2019年6月5日单词
    2019年5月30日单词
    used to do 与be used to doing /n.
    Json.Net(一)介绍
  • 原文地址:https://www.cnblogs.com/qynprime/p/11959164.html
Copyright © 2011-2022 走看看