【发布时间】:2020-05-26 16:34:30
【问题描述】:
我正在使用 webview 加载我的网页,大部分工作正常,但页面导航栏变得额外宽度并将导航栏按钮放置在右侧,您必须滚动才能找到按钮:
这是它的外观: https://i.gyazo.com/abce79b5e38f873612bb27b48ca7d451.png
下面是白色空白区域的按钮: https://i.gyazo.com/9e7bbd1f9d5e48a833065a23a4275881.png
我试过了:
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
没有成功
也试过了:
webview.setInitialScale(1);
我明白了,你可以看到按钮出现但空白仍然存在: https://i.gyazo.com/8bcec562fba5d48716048c501931063c.png
在水平方向上,我做对了: https://i.gyazo.com/c549be715f15e115c7238f679a4384aa.png
这是它在浏览器中的外观以及它在我的应用程序中的外观: https://i.gyazo.com/f671f8881ad15b10ce2207182cb4b11f.png
这是我在 android 中的代码:
WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_main);
webview = (WebView) findViewById(R.id.pagina);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Ha ocurrido un error" + description, Toast.LENGTH_SHORT).show();
}
});
webview.loadUrl("http://blahblahblah.com");
}
基本上是官方文档的复制/粘贴
这是我在 html 文件中的导航栏部分:
<header>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menusuperior">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-left" href="#">
<img class="img-responsive imagenlogo" src="assets/img/logo2.png">
</a>
</div>
<div class="collapse navbar-collapse" id="menusuperior">
<ul class="nav navbar-nav navbar-right">
<li><a href="#backgroundinfo">Sobre mi</a></li>
<li><a href="#backgroundservicios">Servicios</a></li>
<li><a href="#backgroundcitas">Citas</a></li>
<li><a href="#backgroundconsultorio">Consultorio</a></li>
<li><a href="#backgroundcontactoyubicacion">Contacto</a></li>
<li><a href="https://blahblahblah.blogspot.com.co" target="_blank"> Blog</a></li>
</ul>
</div>
</div>
</nav>
</header>
我为导航栏做了一些自定义样式:
.navbar {
padding-top: 10px;
padding-bottom: 10px;
border: 0;
border-radius: 0;
margin-bottom: 0;
font-size: 18px;
letter-spacing: 2px;
background-color: #3d4451;
}
.navbar-nav {
padding-top: 25px;
}
.navbar-nav li a {
color: white !important;
text-decoration: none;
}
.navbar-nav li a:hover {
color: #00afa6 !important;
}
@media screen and (max-width: 768px) {
body {
padding-top: 0px;
margin-top: 50px;
}
.navbar {
padding-top: 0px;
padding-bottom: 0px;
}
.navbar-nav {
font-size: 18px !important;
letter-spacing: 2px !important;
position: relative !important;
left: 0px;
}
}
提前感谢您的帮助
【问题讨论】:
-
添加一些代码。只有图像没有帮助。
-
我们可以提供您的网站链接或任何有效的小提琴吗?我们无法调试图像
-
来自安卓应用还是网站?
-
好的,所有涉及的代码都添加了,希望你能帮助我
标签: android html css twitter-bootstrap-3