【发布时间】:2017-07-15 04:07:35
【问题描述】:
在我的应用程序中,我使用网页的 url 在 webview 中显示网页。 url 加载正常,但问题是网页的某些内容是从底部裁剪的。如何解决这个问题?任何帮助将不胜感激。 这是我的代码
xml代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg_color"
>
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
layout="@layout/empty_result_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Java 代码
String Content = "<h2>" + ItemDetail.getTitle() + "</h2>\n" + ItemDetail.getWebviewContent();
Content = Content.replaceAll("a href=\"/", "a href=\"" + ConstantFile.SERVER_ADDRESS + "/");
webview.loadDataWithBaseURL(null, Content, "text/html", "UTF-8", null);
webview.getSettings().setDefaultTextEncodingName("UTF-8");
【问题讨论】:
标签: android webview android-webview android-xml android-designer