安卓工作室制作的应用程序超过了手机宽度



我为我的博客制作了一个应用程序。博客在使用浏览器时看起来不错,但使用应用程序时它超过了屏幕宽度。这是我的博客

这是我从浏览器(opera、yandex等(中看到的
以及使用应用的结果

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipe_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="WebViewLayout" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

和主要活动xml

解决方案是在我的java文件中添加这两行。多亏了这个答案

webView.getSettings().setUseWideViewPort(true);
webView.setInitialScale(1);

相关内容

最新更新