android - Android studio webview显示bug
问题描述
电池居中,但我没有使用任何边距或填充,我不知道该怎么做。我也用我的手机代替模拟器,但同样的问题。我试图在 chrome 中更改屏幕类型,它工作正常。
我的html代码:
<style type="text/css">
html, body {height: 100%;}
h1,h2,h3,h4,h5,h6,p{color: white;}
.pg2Header{
background-color: #131313;
border-radius: 0px 0px 150px 150px;
width: 100%;
height: 25%;
padding-top: 10%;
padding-left: 10%;
}
.statusTx{
font-size: 30px;float: left;;width: -moz-fit-content;width: fit-content;display: table;
}
.status{
background-color: rgba(234,250,170,255);
width: 45%;
height: 20%;
border-radius: 20px;
padding-left: 1.5%;
float: left;
}
</style>
<div class="pg2Header"><div><h1 style="float: left; font-size: 60px;">barbelio b1</h1><img style="margin-left: 10px;height: 30%;width: 20%;" src="barbell.png"><img src="settings.png" style="margin-left: 30%;height: 40%;width: 7%;margin-bottom: 1%;"></div><img src="battery_big.png" style="margin-top: 7%"><div style="margin-top: 13%;width: 40%;float: right;"><h6 class="statusTx">Status:</h6><div class="status"><h6 style="color: black;" class="statusTx">Connected</h6></div></div></div>
我的科特林代码:
class MainActivity : AppCompatActivity() {
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val myWebView: WebView = findViewById(R.id.webview)
WebView.setWebContentsDebuggingEnabled(true);
myWebView.settings.javaScriptEnabled = true
myWebView.settings.domStorageEnabled = true;
myWebView.webChromeClient = WebChromeClient()
myWebView.addJavascriptInterface(WebAppInterface(this), "Android")
myWebView.loadUrl("file:///android_asset/index.html")
}
}
解决方案
推荐阅读
- macos - VirtualBox 在 MacOS X Catalina 上在后台运行一段时间后变慢
- python - 使用 * 将值打包到元组中,就像函数参数打包一样
- excel - 使用 VBA 打开受密码保护的 Excel 文件
- c# - 如何为多个项目构建一个 docker 镜像?
- node.js - 构建成功后,React Native 中的应用程序无法在设备中打开
- elasticsearch - 如何使用 FluentD 和 ELK ElasticStack 配置证书授权
- cassandra - 如何在 apache cassandra 3.11.4 中启用 G1 gc
- apache-spark - OSError:[Errno 22] Spark Streaming PySpark 中的参数无效
- scala - 这是基于条件在 Scala 中创建对象的最佳方法吗?
- flask - 服务器发送事件仅发送静态数据 - Flask